Keystone 🤝 Next.js

  • If you are not logged in, you can only see the name of all users in the database.
  • User.email is behind access control and only visible for logged in users. Once you log in, you can see both the name and email of all users in the database.

Users fetched from the server (in getServerSideProps)

  1. Clark Kent (email: not authenticated)
  2. Bruce Wayne (email: not authenticated)
  3. Diana Prince (email: not authenticated)

Users fetched from the browser (in useEffect())

loading...

How does it work?

Keystone's APIs can be seamlessly composed to work as a powerful data engine within Next.js applications without having to host a separate Keystone server. This is made possible by Keystone's `getContext` API.

  • CRUD data within your Next.js server: You can use the Keystone data APIs directly in Next.js `getStaticProps` or `getServerSideProps` to CRUD data. ⚡️
  • CRUD data from browser: You can use the generated Keystone GraphQL schema to setup your own GraphQL server in a Next.js route. This enables you to send GraphQL requests from the browser. 🤯

Note: Since you are not starting the keystone server, the Admin UI will not be available. You can host Keystone as a separate server if you need Admin UI.

Check out the example in the repo more info.