FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Fauna Add-on for Netlify
The Fauna Add-on for Netlify makes it easy to use Fauna as the database for your Netlify sites and functions.
Overview
Fauna is a serverless cloud database that offers fast global access to data using modern APIs without sacrificing data consistency. Ubiquitous, flexible, and secure, Fauna helps modern developers build applications fearlessly. It is an ideal companion for your serverless web applications hosted by Netlify, an excellent choice for web site hosting and development.
The Fauna pricing model provides a generous free plan, which makes it ideal for developing your web application. You only pay when you exceed the thresholds for free service. See the pricing page for details.
Fauna multitenancy features make it easy to create and manage per-client databases, which simplifies your application development considerably. Create a database for a specific client, and create and store a key for that database. When the client logs in, use the stored key to access the client database. You don’t need to worry about connection pooling, or data segregation. Fauna is accessed using HTTPS and there is no cross-database data contamination.
When you setup the Fauna Add-on for Netlify, a Netlify-specific database is created in Fauna, an access token is created and stored in a Netlify environment variable, and the JavaScript driver is installed. Everything you need to get started building a Netlify function that uses Fauna for persistent data storage.
How to use the Fauna Add-on for Netlify
It only takes a few minutes to get setup.
-
Sign up for a Netlify account
You can skip this step if you already have a Netlify account.
-
Install the Netlify command-line tool
You can skip this step if you have previously installed
netlify-cli
.In a terminal, run the following command:
npm i netlify-cli -g
-
Create a folder for your Netlify project
If you already have a Netlify project created,
cd
into that folder in your terminal, then skip to the next step.In your terminal, run the following commands:
mkdir my_project cd my_project
-
Initialize your Netlify project
If you have already initialized your Netlify project, skip to the next step.
In your terminal, run the following command:
netlify init
-
Add the Fauna Add-on for Netlify
In your terminal, run the following command:
netlify addons:create fauna
-
Authenticate the Add-on
In your terminal, run the following command:
netlify addons:auth fauna
This step prompts you to sign up with Fauna, or login if you already have an account. Once logged in, you are prompted to name your database and import it into your account. This allows you to interact with your database directly using the Fauna Dashboard.
The database created for your project gets a generated name, which
looks like c7d7da35-e79a-4cad-88cd-83a152b50793 . You can freely
rename the database, using the Fauna Dashboard or fauna-shell ,
to make it easier to identify to which project it belongs.
|
Netlify environment variables
Once the Fauna Add-on for Netlify is setup, access tokens are available in the following Netlify environment variables:
-
FAUNADB_ADMIN_SECRET
: A secret with the admin role. This secret grants full access to parent of the created database. -
FAUNADB_SERVER_SECRET
: A secret with the server role. This secret grants full access to the parent of the created database, but none of its child databases. -
FAUNADB_CLIENT_SECRET
: A secret with the client role. This secret grants access only to documents with thepublic
permission in the parent of the created database. Typically, this means no access.
Done
You’re all done setting up the Fauna Add-on for Netlify.
The next step is to build your web application or microservice. See the Netlify documentation for help there.
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!