Repository navigation
Use Nextjs handler in API routes to be able to use renderToHTML #10721
Unanswered
janus-reith
asked this question in
Help
Replies: 1 comment 12 replies
The case you're describing is already covered by getStaticProps: However it's not documented in the RFC yet, will be a separate rfc. |
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
There are some usecases where pages need to display up to date data, which doesn't exist during the build step and can't be fetched on clientside, e.g. product pages in a Catalog which needs a good SEO.
As I have not found a way yet to render static pages on demand or something smilar to cover this usecase, it seems like using Initial props / getServerProps together with some page cache would still be the most feasible solution.
Using a Cache for SSR pages currently requires using a custom Server.
The example implementation uses the
cacheable-responsepackage and then callsrenderToHTMLof the nextjs app handler.In my API route I only have access to
resandreq. Would it be possible to makerenderToHTML, or maybe even other next handler functionality available over these API routes?BTW: I would also appreciate other suggestions on how to solve the underlying issue described above :)
All reactions