Romaji to Kana Converter: Astro — Chapter 1, Exercise 3
=====================================================================
TASK
Without installing any adapter, add export const prerender = false;
to the top of a scratch page in your own project and run a real
production build with npm run build. Observe what actually happens,
and explain -- tying it back to this chapter's own finding -- exactly
why on-demand rendering can't work without one.
SOLUTION
Create a real scratch page, e.g. src/pages/scratch.astro:
---
export const prerender = false;
---
This page wants to render on demand.
Then run:
npm run build
The build fails before it ever produces a working site. Rather than
quietly ignoring the flag or falling back to prerendering the page
anyway, Astro's own build process stops and reports that on-demand
rendering was requested but no adapter is configured to actually run
it -- because prerender = false isn't a hint or a suggestion, it's an
instruction to generate a page that has to be executed by a real
server at request time, and without an adapter there is no server
runtime for Astro to hand that job to.
This is the exact same requirement this chapter's own finding-box
already named for Premier League Predictor: Astro, just seen from the
opposite direction: that course installs the @astrojs/node adapter in
its own first chapter specifically because it needs on-demand routes
from day one, while this course deliberately leaves the adapter out
because nothing in it needs on-demand rendering yet. The moment any
page in this project actually asks for prerender = false, an adapter
stops being optional and becomes a real, load-bearing requirement --
which is exactly the situation Chapter 5 deliberately walks into on
purpose, once it's time to build and compare a real server-rendered
version of the converter.
WHY THIS WORKS AS AN ANSWER
----------------------------
It doesn't just report that the build fails -- it explains the real
mechanism behind the failure (prerender = false commits a page to
running on a server at request time, and an adapter is what supplies
that server runtime) and connects it back to the chapter's own
comparison between this course's adapter-free setup and its Premier
League Predictor: Astro sibling's adapter-from-day-one setup.