This project is based on the Angular Universal Starter project and demonstrates how to use Angular Universal for prerendering content from Prismic.io
Prerendering gives an Angular SPA the speed and SEO friendliness of a static website without the need of a server.
Prismic is a Headless CMS.
Goal | SSR | Prerendering |
---|---|---|
performance | fast | fastest |
hosting cost | ~$30/m | $0 |
complexity | highest | lowest |
static hosting | No | Yes |
scale limitations | Unlimited | Yes |
(from AngularFirebase)
- Uses ZoneMacroTaskWrapper encapsulated on
async-api-call-helper.service.ts
to make Angular Universal wait for Prismic API calls before rendering. - Uses TransferState service to prevent flickering in the server to browser transition.
Prerender
- Happens at build time
- Renders your application and replaces the dist index.html with a version rendered at the route
/
.
npm install
oryarn
- run
npm run start
which will startng serve
npm run build:prerender && npm run serve:prerender
- Compiles your application and prerenders your applications files, spinning up a demo http-server so you can view it on http://localhost:8080
Note: To deploy your static site to a static hosting platform you will have to deploy the dist/browser
folder, rather than the usual dist