FaunaDB Next.js Example
The FaunaDB example shows how you can use WunderGraph with FaunaDB and Next.js.
WunderGraph integrates with FaunaDB out of the box, no complex configuration is required.
Before we can start, you've got to set up a FaunaDB account and create a database. Please follow the steps below.
Create a FaunaDB account.
Create a database with the following options:
- Region Group: Choose the one that works best for you.
- [x] Use demo data.
Create a API token under
- Key Name:
Write down the secret displayed: if you lose it, you have to create a new one (the secret is only ever displayed once).
Rename the file
<replace-with-your-token>with the secret from step 4.
If you selected a Region Group other than Classic, replace
https://graphql.fauna.com/graphqlwith the GraphQL API endpoint suitable for your selected region group:
Once the environment is set up, we're ready to configure our application.
This configuration adds
faunaDB as a data source and configures the API key to be used. The API key of your FaunaDB instance is not exposed to the client, making it a perfect fit to secure your API.
Add an Operation
Now that everything is configured, let's add an Operation.
Calling the Operation from Next.js
And that's it! We've fully integrated FaunaDB, WunderGraph and Next.js.
Deploy to WunderGraph Cloud
The easiest way to deploy your WunderGraph app is to use WunderGraph Cloud . Enable the Vercel integration to deploy the Next.js frontend to Vercel.