question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next-routes two components with same main route

See original GitHub issue

Hi, I want to have this configuration in the routes file with next-routes:

module.exports = routes()
.add({ name: "perfil", pattern: "/perfil/:id", page: "perfil" })
.add({ name: "edit", pattern: "/perfil/:id/edit", page: "edit" })

One component called “edit” that has the route /perfil/:id/edit and other for “perfil” which is /perfil/:id.

But that does not work, the component “perfil” gives me the route /perfil/:id and the component “edit” gives me /edit. How can i resolve this?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
AugustinLFcommented, Jun 12, 2019

You should put the most specific first. Because here /product/123 matches /:id, where id is product/123.

1reaction
MontoyaAndrescommented, Jun 12, 2019

@juliankoehn the example you sent is using now, which is great, I use it. But what I was talking about is this https://github.com/zeit/next.js/blob/canary/packages/next/README.md#custom-server-and-routing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing: Introduction - Next.js
The Next.js router allows you to do client-side route transitions between pages, similar to a single-page application. A React component called Link is...
Read more >
How can I use one component (page) for multiple route in ...
Inside the route directory you can import and export the component from another directory. Inside your second route /myPage2/index.js :
Read more >
fridays/next-routes: Universal dynamic routes for Next.js - GitHub
This file is used both on the server and the client. API: routes.add([name], pattern = /name, page = name); routes.add(object).
Read more >
A Beginner's Guide to Routing in Next.js, with Examples
The site will have two simple routes and two dynamic routes (we'll get to the meaning ... Next.js also provides us with a...
Read more >
Routing in Next.js – A Complete Beginner's Guide
A page in Next.js is a React component that has a route based on its file name. Consider this folder structure as an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found