Routing by filename: brackets instead of config

How Jeasx maps files to URLs, and why wrapping a filename in brackets is all the routing configuration you need.

Jonas Weber1 min read

In Jeasx, only files with brackets in their name become routes. A file called [index].jsx answers the folder it lives in, while [...path].jsx catches everything below it. This blog uses exactly that: the overview is an index route and every post is answered by a single catch-all route which looks up the slug.

Guards are routes too. A [...guard].jsx runs before all routes in its folder and can stop the request by returning a response. The form for new posts is protected this way with Basic Auth, without touching the form itself.

Files without brackets, like posts.js next to the routes, are ordinary modules. They can be imported, but never requested from the outside.