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.
Fauna 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, 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.
Fauna’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.
Fauna’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; Fauna is accessed via 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 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 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 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
Fauna 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 Fauna 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 Fauna documentation for help writing queries and managing your data.
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!