can we use react-router-dom to switch routes in gatsby app
See original GitHub issueSummary
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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
/src/pages/index.js
@reach/router
, but you could usereact-router
.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.
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 doesMarking 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 💜