Gatsby App - Templates vs Client only routes
See original GitHub issueI am building a gatsby app at https://sherpafeet.com
One of the issues I am seeing with client only routes is, if we refresh the page we get a 404, as it is a client only route and doesn’t exist on the server.
Since we can do data fetching while loading a page, we could do a createPage on a template file in gatsby-node.js
, so when should I be using client only routes vs a template file which does conditional rendering after fetching data at runtime?
Hope the question is clear!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Client-only Routes & User Authentication - Gatsby
Client-only routes will exist on the client only and will not correspond to index.html files in an app's built assets in the /public...
Read more >Using client-only routes with page templates coming from ...
I assume that gating content from a CMS is possible with Gatsby but I might be wrong given it is an SSG. I...
Read more >App-Like Features of Gatsby – Create Client-Only Routes
Create Client-Only Routes. While Gatsby is extremely powerful at prerendering content, it's also great for client-only apps. With the addition of dynamic ...
Read more >gatsby-example-client-only-paths - CodeSandbox
CodeSandbox is an online editor tailored for web applications. ... gatsbyjs / gatsby-starter-default / master ... gatsby-example-client-only-paths.
Read more >Gatsby Tutorial #3 - Pages & Routes - YouTube
Hey gang, in this Gatsby tutorial we'll talk about how to create pages (page components) and the routes generated for those pages.
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 FreeTop 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
Top GitHub Comments
While it is true that you can conditionally render anything you like, there are often “internal” admin pages (that are unique to every logged in user) which don’t benefit from any build time SSR at all.
These are the sort of pages that client only routes are relevant for.
TL DR: If you want to skip build time SSR for a page and make it client side only, use a client only route.
Does that make sense? Happy to answer any other questions.
@freiksenet As per the documentation, client only routes are for:
Often you want to create a site with client-only portions, which allows you to gate them by authentication or load different content based on URL parameters.
To gate information using authentication, we can do a fetch from within any page and conditionally render. We do not really need client only routes, correct me if I am wrong.
To load different content based on URL parameters - We can use templates to contruct different urls and pageContext to fetch data at runtime.
I am trying to grasp a use case for client only routes, which cannot be done without it.
re-opening issue.