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.

Handling dynamic routes

See original GitHub issue

Using React-snap with React Router (5.1.5)

<Switch> <Route path="page/:id"> <Page /> </Route> <Route path="page"> <Page /> </Route> </Switch>

After the build, it creates page.html so I page without params works (http://url/page). However, if I try something like this http://url/page/3, I get 404 page.

How can I make the dynamic routes work?

Edit: Normally using HashRouter instead of BrowserRouter solves the problem without SSR.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:7

github_iconTop GitHub Comments

3reactions
ricky11commented, Aug 9, 2021

How would this work if we dont know the dynamic link path?

for example /download/slug*
where slug is a 5 digit random sequence of letters

I’m not sure how react-snap will create a index.html in a /download/??? folder ?

2reactions
urosrancommented, Dec 2, 2020

@BrightonNgema thanks for the answer! As I have an album component and each image is a route to a store (in an e-mall) the following worked: <Link to={'/' + yourUrl} style={{display: 'none'}}>linkToStore</Link>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Routes - Next.js
Dynamic Routes are pages that allow you to add custom params to your URLs. ... Client-side navigations to dynamic routes are handled with...
Read more >
Routing in Next.js – How to Set Up Dynamic Routing with Pre ...
In this tutorial, you'll learn how to set up dynamic routing in Next.js. You'll also learn about pre-rendering and why it's important.
Read more >
A Beginner's guide to Dynamic Routing in Next.js - Marie Starck
Tutorial on Next.js Dynamic Routing. How to create routes and navigate between pages with Link, useRouter and withRouter (next/link and ...
Read more >
Get Data using Dynamic Routes in React - DEV Community ‍ ‍
One of the most common needs we all have is consuming data in the frontend dynamically and one of the solutions is the...
Read more >
Handling Dynamic Routes Without a Server - Stack Overflow
"I think this architecture demands that there's either a server to handle route redirects or a SPA framework." — No, it demands that...
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