Skip to main content



Please note that routing is environment specific. The details documented below only apply to server mode since serverless environments will have their own custom routing


Under the hood, light uses find-my-way to route in server mode. find-my-way turned out to be one of the fastest routers available while allowing for advanced features such as hot module reloading. Reading the find-my-way documentation in conjunction with this guide may help you understand light's router better.

Automatic Routing#

When in server mode, light will try to guess the route based on its location in the directory. It is very similar to how Next.js does its routing. Any file that ends with index.js will be collapsed to the root. So for example, the route routes/users/index.js will be treated as /users. All other routes will follow the system path. For example creating a file in routes/posts/new.js will yield the route /posts/new.

Additionally, to support dynamic urls such as /users/:username, simply create a file called [username].js in the users folder. You can then use the params in the Context to fetch the username, detailed here.