Replies: 1 comment 1 reply
-
Thanks @dillonraphael this is definitely something we could add. Blitz actually compiles your code into a Next.js app, so if we added config-based routing, during our compile step we would convert the config to actual files inside So let's use a concrete example of how this might work. For a route of
or like this
But we would definitely want to figure out a way to make this work really nice with typescript so that you could have statically typed routes to use with <Link href={routes.products.new}>Create new product</Link> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What do you want and why?
I've been working on a new project with Blitz, and coming to realize how complicated things can get with nested routes.
Imagine you need a route like
/store/4489/products/38490/edit
, you would have to nest 4 levels inside a directory. Of course it's manageable, but hurts my head.Possible implementation(s)
We can have either a single
router.js
file in the project root, or arouter.js
file per resource.The router file it self can take advantage of Next.js
getStaticPaths
, but the issue with this is we would have to rebuild the project every time we add a new route.We can also hook into the custom server, but according to Next.js docs:
Additional context
There can be a flag when generating a new blitz project that will ask the user if they want to define routes them self. Then simply add
useFileSystemPublicRoutes: false
toblitz.config.js
.We shouldn't get rid of the pages directory, even if the user defines their own routes. The custom routes will just override directory routing.
Beta Was this translation helpful? Give feedback.
All reactions