FileRoutes
The FileRoutes
component builds a set of Hydrogen routes. By default, it loads the routes specified in the Hydrogen configuration file when no props are passed.
You can override the default behavior and use custom routes based on the output that's provided by Vite's import.meta.globEager method. You can have multiple instances of the FileRoutes
component to source file routes from multiple locations.
Example code
Anchor link to section titled "Example code"
Name | Type | Description |
---|---|---|
routes? | ImportGlobEagerOutput |
The routes defined by Vite's import.meta.globEager method. |
basePath? | string |
A path that's prepended to all file routes. You can modify basePath if you want to prefix all file routes. For example, you can prefix all file routes with a locale. |
dirPrefix? | string | RegExp |
The portion of the file route path that shouldn't be a part of the URL. You need to modify this if you want to import your routes from a location other than the default src/routes . |
Component type
Anchor link to section titled "Component type"The FileRoutes
component is a server component that renders inside App.server.jsx
. For more information about component types, refer to React Server Components.