-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Routing #929
Comments
You server route should be something like this: server.get('/notifications/:id', (req, res) => {
const params = { id: req.params.id }
return app.render(req, res, '/notifications/single', params);
}); And you client side Router.push(`/notifications/single?id=${id}`, `/notifications/${id}`); |
Maybe next-routes can be helpful to you, you could use it like this: routes.add('notification', '/notifications/:id', 'notifications/single')
routes.add('notifications', '/notifications', 'notifications/index')
Router.pushRoute('notification', {id: 1})
Router.pushRoute('notifications')
<Link route="notification" params={{id: 1}}> ... </Link> |
@arunoda that makes sense cheers :) Works! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
I know this has been discussed in a few other places and also there is a example repo for express, however I'm struggling to get this working with the examples and help on slack:
I need two routes:
/notifications
(pages/notifications/index.js)/notifications/:id
(pages/notifications/single.js)My server (express) is setup to like so:
On the server
getInitialProps
I can grab the ID fromctx.req.params
. However, I'm struggling to navigate to the route usingRouter
./notifications
route.Is there anyway to handle this?
Cheers
The text was updated successfully, but these errors were encountered: