Skip to main content
The Vertz router provides type-safe, file-system-free routing with loaders, nested layouts, and search param parsing. Route patterns are inferred from your route map, so typos in navigate() calls and missing params are caught at compile time.

defineRoutes()

Define your route map. The const modifier preserves literal path types for type-safe navigation.

Signature

RouteConfig


createRouter()

Create a router instance from a route definition.

Signature

Parameters

RouterOptions

Router<T>


RouterView

Renders the component matched by the current route.

Props


Outlet

Renders nested child routes inside a layout component. Must be used within a component rendered by RouterView.

useRouter()

Access the router instance from any component in the tree. Must be called within RouterContext.Provider (set up automatically by RouterView).

Signature

In scaffolded apps, codegen writes .vertz/generated/router.d.ts, which augments useRouter() with your app’s route map so navigate() is typed by default. You can still pass a generic manually in non-generated setups.

useParams()

Read the current route’s parsed parameters.

Signature

When a params schema is defined on the route config, useParams() returns the parsed values (e.g., id as number instead of string).

useSearchParams()

Read and write the current route’s search (query) params as a reactive proxy. Reads trigger signal tracking; writes batch-navigate to update the URL.

With a search params schema

Define a schema on the route to get typed, coerced values:

Signatures

ReactiveSearchParams

SSR behavior

During SSR, reads return the values from the request URL. Writes throw an error in development to catch accidental server-side mutations.
Create a Link component factory bound to a router’s state. Used internally — most apps use the Link component via RouterView setup.

LinkProps


Types