FaunaDB Add-on for Netlify

The FaunaDB Add-on for Netlify makes it easy to use FaunaDB as the database for your Netlify sites and functions.

FaunaDB is a serverless cloud database that offers fast global access to data via modern APIs, like GraphQL, without sacrificing data consistency. Ubiquitous, flexible, and secure, FaunaDB 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.

FaunaDB’s pricing model provides a generous free tier, 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.

FaunaDB’s multi-tenancy features make it easy to create and manage per-client databases, which simplifies your application development considerably. Just 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’s database. You don’t need to worry about connection pooling, or data segregation; FaunaDB is accessed via HTTPS and there is no cross-database data contamination.

When you setup the FaunaDB Add-on for Netlify, a Netlify-specific database is created in FaunaDB, an access token is created and stored in a private environment variable (the Netlify UI never displays it), and the JavaScript driver is installed. Everything you need to get started building a Netlify function that uses FaunaDB for persistent data storage.

How to use the FaunaDB Add-on for Netlify

It only takes a few minutes to get setup.

  1. Sign up for a Netlify account

    You can skip this step if you already have a Netlify account.

  2. 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
  3. 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
  4. 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
  5. Add the FaunaDB Add-on for Netlify

    In your terminal, run the following command:

    netlify addons:create fauna
  6. Authenticate the Add-on

    In your terminal, run the following command:

    netlify addons:auth fauna

    This step prompts you to sign up with FaunaDB, 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 FaunaDB Console.

The database created for your project receives an auto-generated name, which looks like c7d7da35-e79a-4cad-88cd-83a152b50793. You can freely rename the database, via FaunaDB Console or fauna-shell, to make it easier to identify to which project it belongs.

That’s it!

You’re all done setting up the FaunaDB Add-on for Netlify.

The next step is to build your web application or microservice. See the Netlify documentation for help there. Check out the rest of the FaunaDB documentation for help writing queries and managing your data.

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!