DEV Community

Discussion on: Prerender an Angular app

Collapse
 
ionellupu profile image
Ionel Cristian Lupu

99% of the time you won't have the user-routes file written manually. The routes in there should be automatically generated using some data from the database. How would you approach this?

Collapse
 
maj07 profile image
Majuran SIVAKUMAR

Hello @ionellupu 👋
Yes the route file was written manually for the purpose of this article.

I agree often you will have to generate this file from an external source like Database, CMS / API etc.

For example if we take product details pages for a E-commerce, we can get the product ids we need (ex: most viewed) from an api or script that generate the routes file locally or on a cdn. Then we can fetch this file before running our prerender script.

Its a suggestion, but of course it will depends on your over all architecture and needs.

Collapse
 
raulmar profile image
RaĂșl MartĂ­n

Hi @maj07, I understand the approach you propose. However, I see Angular Universal pre-render as a way to run my CI pipe in order to generate all the html and then distribute the static pages on a CDN. So I think it's a bit overkill to have to run a server just to run a script for fetching the routes.