Pages & Routing

Multi-page SPAs from a single file.

Single page

page / { h1 "Home" p "Welcome!" }

Multiple pages

Define multiple pages in one file. NyxCode compiles to a single-page app:

page / { h1 "Home" link "About" href="/about" } page /about { h1 "About" link "Back" href="/" }

Zero-config routing

How it works

Each page compiles to a hidden div. A 20-line router shows/hides pages based on the URL. History API handles browser back/forward. External links leave the SPA normally.

← Quick Start Styling →