defineModule() and defineResource() calls. This approach is similar to Next.js’s App Router.
Overview
Instead of manually assembling module/resource hierarchies, you define pages as files in apages/ directory. The route path is automatically derived from the directory structure.
Setup
1
Configure Vite plugin
Add the
appShellRoutes plugin to your Vite config:2
Create pages directory
Create a
src/pages/ directory in your project.3
Use AppShell without modules prop
No configuration needed—pages are automatically discovered:
Pages are automatically discovered and injected—no
modules prop required!Page components
Minimal example
The simplest page is just a default-exported component:Full example
Use theappShellPageProps static field to configure metadata and guards:
AppShellPageProps type
Path conventions
Examples
Use
(parentheses) for route grouping without affecting the URL path. Use _underscore for shared code that shouldn’t be routed.Dynamic parameters
Use square brackets for dynamic route segments:Multiple parameters
/orders/:orderId/items/:itemId
Route guards
Guards are not automatically inherited from parent pages. Each page must explicitly define its own guards:Reusable guards
To share common guards across pages, compose them from a shared module:Typed routes
EnablegenerateTypedRoutes to generate type-safe route helpers:
src/routes.generated.ts with a paths helper:
Type-safe navigation
Learn more about typed routes
Comparison with legacy API
Before: Explicit hierarchy
After: File-based pages
Concept mapping
Compatibility
File-based pages and explicitmodules prop are mutually exclusive.
Valid patterns
Migration guide
To migrate fromdefineModule/defineResource to file-based routing:
1
Add Vite plugin
2
Create pages directory structure
- Map each module to a top-level directory
- Map each resource to a subdirectory with
page.tsx - Use
[param]for dynamic segments
3
Move component and metadata
4
Remove modules prop
Once all pages are migrated, remove the
modules prop from <AppShell>Related
Routing and navigation
Learn about client-side navigation and typed routes
Modules and resources
Understand the legacy explicit configuration approach