Static Routes

View as Markdown

Static is Neutron's default route mode. The build runs the route, writes its HTML to dist, and serves that file without rendering it again for each request.

export default function About() {
  return <h1>About</h1>;
}

You can make the default explicit:

export const config = { mode: "static" };

What ships to the browser

Neutron does not hydrate the page shell or ship the client router for a plain static route. Your own scripts still run normally, and an Island can hydrate one component without turning the whole route into app mode.

Static routes are appropriate when the response does not depend on the current request. Use app mode for authentication, request-time personalization, actions, or route middleware.

Load data at build time

A static route may export a loader. Neutron runs it during the build and renders its result into the generated page.

import { useLoaderData } from "@neutron-build/core";

export async function loader() {
  return { released: "2026-08-11" };
}

export default function Release() {
  const data = useLoaderData<typeof loader>();
  return <time>{data.released}</time>;
}

Rebuild and redeploy when build-time data changes.

Generate dynamic paths

Dynamic static routes must enumerate their URLs with getStaticPaths:

export const config = { mode: "static" };

export async function getStaticPaths() {
  const posts = await getPosts();
  return posts.map((post) => ({ params: { slug: post.slug } }));
}

export async function loader({ params }) {
  return getPost(params.slug);
}

Each returned parameter set becomes a generated page.