#Detect if request is prerendered or dynamic with output: hybrid
3 messages · Page 1 of 1 (latest)
Hi @dense mural. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
In Astro's hybrid output mode, you can control whether a page is pre-rendered or generated on-request by using the prerender export in your page or endpoint.
To pre-render a page (generate it at build time), you can add export const prerender = true to your page or endpoint. This means that the page will be generated at build time and served statically.
// This route should be generated at build time!
export const prerender = true
(Source: Unlock New Possibilities with Hybrid Rendering (https://astro.build/blog/hybrid-rendering/#why-use-static-analysis))
On the other hand, if you want a page to be generated on-request (not pre-rendered), you can add export const prerender = false to your page or endpoint. This means that the page will be generated on-demand, at the time of the request.
// Mark the page as `prerender = false` to skip pre-rendering
// and run the API endpoint in the server on every submission.
export const prerender = false
(Source: Astro 2.6: Middleware (https://astro.build/blog/astro-260/#hybrid-ssr-output-mode))
Please note that in hybrid mode, pages are pre-rendered by default. So, if you don't specify prerender export, the page will be pre-rendered.