Set up your bootstrapped Next.js app with
npx and move into the project directory:
npx create-next-app --example with-graphql-faunadb my-nextjs-guestbook && cd my-nextjs-guestbook
By including the
create-next-app bootstraps an app based off of a template found in the Next.js examples repository.
With your Next.js app set up, it is ready to deploy live with Now.
Using Now CLI, deploy your website with a single command:
If you want to deploy your Next.js app when you push to a Git repository, you can use either Now for GitHub, Now for GitLab, or Now for Bitbucket to have your project automatically deployed on every push, and the production domain updated on push to master.
The app features a working Guestbook SPA with GraphQL support, connected to an example FaunaDB database.
By importing a GraphQL schema into your database, you gain access to FaunaDB’s versatile GraphQL endpoint. This endpoint automatically resolves GraphQL queries and mutations.
The GraphQL import process generates the requisite Collections, Indexes, and resolvers expected of your schema. FaunaDB also generates CRUD mutations for each GraphQL object.
All of the components for the app are found in the
/styles directory, this is automatically vendor-prefixed when necessary.
graphql/api.js, you will find two GraphQL requests that correspond to a query and a single mutation. These methods fetch guestbook entries and create new ones, respectively.