Using GraphQL in JSS Next.js apps

Version: 22.x

JSS Next.jss apps enable a variety of data fetching options with GraphQL.

Important

You cannot use GraphQL if your app is running in disconnected mode. Instead, make sure that:

  • Your app's fetch method is set to REST.

  • Your app includes the nextjs-styleguide addon.

You can configure a new or existing JSS Next.js application to query the Sitecore GraphQL endpoints, instead of using the equivalent REST APIs.

  • To create a Next.js application that uses the JSS GraphQL API for fetching layout and dictionary data, choose GraphQL when prompted during the app creation process.

  • If you created your Next.js JSS app with REST as the data fetching method, you can reconfigure the sample JSS Next.js app to use GraphQL instead.

Note

In addition to fetching Sitecore data using the JSS GraphQL API, you can query GraphQL endpoints in a similar manner to what you do when developing regular JavaScript applications using connected GraphQL. You can also use connected GraphQL to run queries at the component level.

To write type-protected code with rich IDE assists using GraphQL types and TypeScript static data typing, you can introspect the GraphQL schema.

Do you have some feedback for us?

If you have suggestions for improving this article,