Pular para o conteúdo principal

Routes

Add or remove pages by editing app/config/routes.config.ts.

How it works

The routes config exports a buildRoutes() function that defines your page structure:

// app/config/routes.config.ts
import { index, layout, route } from '@react-router/dev/routes';

export function buildRoutes() {
return [
layout('routes/_layout.tsx', [
index('routes/_index.tsx'), // Homepage
route('profile', 'routes/profile.tsx'), // /profile
route('deposit', 'routes/deposit.tsx'), // /deposit
]),
];
}

Adding a page

  1. Create a new file in app/routes/ (e.g., promotions.tsx)
  2. Add it to buildRoutes():
route('promotions', 'routes/promotions.tsx'),
  1. The page will be available at /promotions

Removing a page

Simply remove the route(...) line from buildRoutes(). You can also delete the corresponding file from app/routes/.

Tips

  • The easiest way to add routes is via routes.config.ts, but you can also modify routes.ts directly if needed
  • All routes should be nested inside the layout('routes/_layout.tsx', [...]) wrapper for the brand/env providers to work
  • Use index() for the default page of a group
  • Use route(path, file) for named pages
  • You can create any components, pages, or hooks you need — the fork is fully yours to customize