Router Service (WORK IN PROGRESS) #151
Replies: 4 comments 17 replies
-
Inspirations : https://nextjs.org/docs/basic-features/pages#pages-with-dynamic-routes |
Beta Was this translation helpful? Give feedback.
-
@mediremi raised this again in #251 - copying here: A common design pattern in our apps is using a grid layout with a sidebar containing navigation menu items on the left and the app content on the right. This pattern is often paired with Issues with current way of doing things
Proposed solution
const config = {
// ...
pages: {
'/': 'src/pages/App.js',
'/some_page/:id': 'src/pages/SomePage.js',
// Route that shoud not visible in sidebar
'/some_other_page': { component: 'src/pages/SomePage.js', sidebar: false }
}
}
module.exports = config and this config would then be used by the app shell to construct a sidebar and router. The runtime would reexport the If |
Beta Was this translation helpful? Give feedback.
-
I thought about this a bit more yesterday. I think we have the following issues if we want to provide a router service: We need some kind of configuration so the service know about the routesfile structureThis makes it a bit more complicated with co-locating page-related and requires introduce a parallel structure (as I've mentioned in my previous comment). If one of our components wants to link to a route, we can't use a constant that holds the route's path and is the single source of truth for that path, which could make changing routes more complicated (although changing routes rarely happens). Config fileCan be read by the service easily and it's declarative, but it sounds like it's almost as much work as just specifying the router in the app. Also it'll make it slightly more difficult to change certain things based on which path is active (e. g. displaying the sidebar or not) as we're decoupling the view from the to-be-mounted components. Config inside source code (e. g.
|
Beta Was this translation helpful? Give feedback.
-
I agree this is a very common pattern and some form of standardisation / automation would be good. Personally I would probably just prefer to implement some components that facilitate this common layout pattern instead of introducing a more rigid configuration based service. |
Beta Was this translation helpful? Give feedback.
-
This is a placeholder for an intra-app (and possibly inter-app) Router Service specification, including both
app-runtime
andapp-adapter
componentsBeta Was this translation helpful? Give feedback.
All reactions