Gatsby: Is is possible to create a `hybrid page` (combined static and client route) (the app-shell model) rather than a `hybrid app` (client-only route)

Created on 9 Jan 2018  路  2Comments  路  Source: gatsbyjs/gatsby

I've been working with Gatsby now for a couple of weeks, merging several different React Apps into one Gatsby React app - so far so good - its great and we are already seeing the benefits.

A use case has come up whereby we are looking to have a _hybrid page_ (static and client route). I can see documentation and examples for creating a _hybrid app_ with client-only routes, however, I'm looking at being able to do the following:

A single static and client route that can have:

  • statically generated _app shell_ - that uses a GraphQL query from a Drupal (or any other) source that creates header, menus, sidebars, CSS etc
  • dynamic URL route
  • dynamic content via a client-side API request (React componentDidMount API request)

I'm ploughing on ahead to hopefully get a sample app to test, but thought I would ask here also.

Much thanks in advance.

question or discussion

Most helpful comment

OK so after some testing, it seems that client-only routes do indeed generate both static and dynamic content on those routes.

If you use Gatsby and GraphQL in layouts to create the static app-shell (for example a GraphQL query to create a menu structure, with container divs and CSS etc) and then use React components with componentDidMount API calls to consume dynamic content.

This is perhaps the whole point of Gatsby client-only routes, however this wasn't clear from the documentation. I will do my best to contribute to the docs for other peoples use.

All 2 comments

OK so after some testing, it seems that client-only routes do indeed generate both static and dynamic content on those routes.

If you use Gatsby and GraphQL in layouts to create the static app-shell (for example a GraphQL query to create a menu structure, with container divs and CSS etc) and then use React components with componentDidMount API calls to consume dynamic content.

This is perhaps the whole point of Gatsby client-only routes, however this wasn't clear from the documentation. I will do my best to contribute to the docs for other peoples use.

Answered by the doc updates on #3579

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  路  3Comments

hobochild picture hobochild  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

theduke picture theduke  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments