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.

can we use react-router-dom to switch routes in gatsby app

See original GitHub issue

Summary

Relevant information

Environment (if relevant)

File contents (if changed)

gatsby-config.js: N/A package.json: N/A gatsby-node.js: N/A gatsby-browser.js: N/A gatsby-ssr.js: N/A

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
piehcommented, Jul 26, 2019

want to switch between routes like we do in app.js in react

You technically could do that using Client-only routes I mentioned before - you can check https://github.com/gatsbyjs/gatsby/tree/master/examples/client-only-paths example that does this:

But with this you would lose automatic per route code splitting and SSR so personally I would not recommend doing that unless you actually have need for dynamic routes.

i also want to pass props while redirecting to other pages

Can you show example of this (can be code snippet with react-router-dom), so I can understand usecase a little better? We might have way to do this without giving up on optimisations (mentioned above) that Gatsby does

0reactions
sidharthachatterjeecommented, Aug 24, 2019

Marking this as answered and closing the issue. Please feel free to comment or reopen if you have any other related questions.

Thank you for using Gatsby 💜

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing | Gatsby
During the build process, Gatsby creates paths to access pages, handling routing for you. Creating navigation for a Gatsby app requires an understanding...
Read more >
Gatsby route v/s React route - DEV Community ‍ ‍
Today I'm going to share a little bit about Gatsby's route. ... to install the react-router-dom package to import BrowserRouter and Route.
Read more >
how to wrap root element in gatsby with BrowserRouter ...
So I have a doubt in case of react apps, we generally wrap the App component in Router of react-router-dom, so in case...
Read more >
Routing not working using Gatsby - reach-router
I switched to reach router as suggested in another post but that doesnt work. I kept getting this error when I used react-router-dom:...
Read more >
Gatsby Routing - GeeksforGeeks
Gatsby is a free and open-source framework based on React that helps developers build blazing-fast websites and apps. Gatsby's sites are ...
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