Filesystem Routing

By default vite-plugin-ssr does Filesystem Routing: the URL of a page is determined based on where its .page.js file is located.

FILESYSTEM                        URL              COMMENT
pages/               /about
pages/index/         /                (`index` is mapped to the empty string)
pages/               /HELLO           (Mapping is case sensitive)

The directories pages/, src/, and index/ are mapped to the empty string ''. For example:

FILESYSTEM                                      URL
src/pages/jobs/                    /jobs
pages/pages/src/src/index/pages/   /about

Which allows us to have a domain-driven file structure such as:

FILESYSTEM                        URL
user/pages/           /user/list
user/pages/         /user/create
todo/pages/           /todo/list
todo/pages/         /todo/create

We can also change the base of the Filesystem Routing with

To define advanced routes, we define Route Strings or Route Functions in .page.route.js files.

Edit this page