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.page.js               /about
pages/index/index.page.js         /                (`index` is mapped to the empty string)
pages/HELLO.page.js               /HELLO           (Mapping is case sensitive)

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

FILESYSTEM                                      URL
src/pages/jobs/index.page.js                    /jobs
pages/pages/src/src/index/pages/about.page.js   /about

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

FILESYSTEM                        URL
user/pages/list.page.js           /user/list
user/pages/create.page.js         /user/create
todo/pages/list.page.js           /todo/list
todo/pages/create.page.js         /todo/create

We can also change the base of the Filesystem Routing with _default.page.route.js#filesystemRoutingRoot.

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

Edit this page