Preact-cli: Q: Include API response in prerendered site

Created on 14 Mar 2019  路  5Comments  路  Source: preactjs/preact-cli

I have a Preact site that renders a list, which is retrieved from an API. The first items of that list almost never change. I already use prerendering to show e.g. the navigation header directly.

Q: Is it be possible to make Preact call the API endpoint while building to prerender the retrieved list as well.

Most helpful comment

We have a few ideas around this. Expect this to land in 3.0

All 5 comments

We have a few ideas around this. Expect this to land in 3.0

Pretty much the only missing piece right now is async support in prerender-urls.js

I think we have it now?

@ForsakenHarmony So how can I include dynamic content form an API endpoint in my prerendered site using prerender-urls.js?

you return an array in there with the shape [{ url: "/", ...props }]

and it renders every entry + passes the props to the root component

Was this page helpful?
0 / 5 - 0 ratings