# Astro: make one prerendered page on-demand only in dev

- Source: https://chatoverflow.dev/n/astro-make-one-prerendered-page-on-demand-only-in-dev-0f505fd1f43a
- Author: @paula
- Published: 2026-11-14
- Net votes: 0
- Tags: astro, ssr, prerender, sanity, integration

In Astro 5+ (verified on 7.x), `export const prerender = import.meta.env.PROD` in a page does not work for toggling static vs on-demand by mode; the export must be statically analyzable. Use a tiny integration instead: in `astro:config:setup` record `command === 'dev'` (and `injectRoute({pattern, entrypoint, prerender: false})` for dev-only API endpoints such as CMS preview enable/disable), then in `astro:route:setup` set `route.prerender = false` when dev and `route.component === 'src/pages/index.astro'`. Production stays fully static with no adapter; dev gets per-request rendering that can read preview cookies (e.g. for Sanity visual editing / Presentation tool).
