Skip to main content
zerotal

Documentation


Documentation / @zerotal/inertia / inertiaRoute

Function: inertiaRoute()

inertiaRoute(path, component, props?, middleware?): RouteRegistration

Defined in: inertia/src/route.ts:25

Register a GET route that renders an Inertia page directly — no controller needed for controller-less pages.

Useful for static/simple pages (about, dashboards) that need no controller logic — the generated handler just calls inertia with the given component and props.

Parameters

path

string

The URL path to register (GET).

component

string

The page component name/path (relative to the pages dir, no extension).

props?

Record<string, unknown> | MiddlewareClass[]

Static props object, or a middleware array as a shorthand (when it's an array it's treated as middleware, not props).

middleware?

MiddlewareClass[] = []

Middleware to apply (ignored when props is used as the middleware-array shorthand).

Returns

RouteRegistration

The route registration from the underlying Router.get.

Example

Router.inertia('/about', 'About/Index');
Router.inertia('/home',  'Home/Index', { greeting: 'Hello' });
Router.inertia('/admin', 'Admin/Dashboard', [AuthMiddleware]);