This simple Guestbook SPA example shows you how to use FaunaDB's GraphQL endpoint in your Next.js project. [Live demo].
By importing a .gql
or .graphql
schema into FaunaDB (see our sample schema file), FaunaDB will generate required Indexes and GraphQL resolvers for you -- hands free 👐 (some limitations exist).
You can start with this template using create-next-app
or by downloading the repository manually.
To use a live FaunaDB database, create one and import this example's schema.gql
file using the FaunaDB console. Create a client secret, then paste it into next.config.js
.
Download create-next-app
to bootstrap the example:
npm install -g create-next-app
create-next-app --example with-graphql-faunadb
Download the example or clone the repo:
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-graphql-faunadb
cd with-graphql-faunadb
Install, then run the development server:
npm install
now dev
Make sure to leave us a guestbook message in our live demo! 😉
Deploy it to the cloud with now! Install now on your development machine before proceeding.
now