Skip to main content
Veryfront uses file-system based routing. Folders and files under app/ (or pages/) define routes; layouts compose down the tree; brackets in path segments mark dynamic params. Examples below use the default app router. Set router: "pages" in veryfront.config.ts to switch to the pages router.

Prerequisites

  • A project created with veryfront init (see Create project).
  • The dev server is the easiest way to test routes: veryfront dev.

Router equivalents

Veryfront supports both router styles. The main difference is file shape: Use the app router when you want the newer directory-per-route shape. Use the pages router when you want the flatter file-per-route layout.

Basic pages

A page exports a default React component:
Run veryfront dev and open http://localhost:3000. The page should render Welcome.

Layouts

Layouts wrap pages and persist across navigation. Create layout.tsx at any level:
Nested layouts compose automatically:
/dashboard/settings renders inside both the root layout and the dashboard layout.

Dynamic routes

Use brackets for dynamic segments:
Access params via the usePageContext hook:
Open http://localhost:3000/blog/hello. The page should render Post: hello.

Catch-all routes

Use [...segments] to match multiple path segments:

MDX pages

Rename any page to .mdx to write content in Markdown with JSX:
MDX pages support frontmatter:
Access frontmatter from components using usePageContext() from veryfront/context:

Client components

By default, components render on the server. Add 'use client' to make a component interactive:
Use the Link component for client-side navigation:
Veryfront can prefetch eligible internal links before navigation. Use prefetch={false} when a link must not prefetch. Programmatic navigation:

Verify it worked

Start the dev server and request each page you added:
Each request should return HTTP/1.1 200 OK. Visit the same URLs in a browser to confirm the React component renders without console errors.