Vercel integration

The Fauna integration for Vercel makes it easy to use Fauna as the database for your Vercel sites and serverless functions.

When you add the integration to your Vercel projects, the integration guides you through the process of connecting your project to a specific Fauna database. Once that is complete, your project can access your Fauna database using FQL to create, retrieve, update, and delete documents.

How to add Fauna to your Vercel projects

It only take a few minutes to get setup:

  1. Sign in to your Fauna account

    If you do not already have a Fauna account, sign up. It’s free!

  2. Sign in to your Vercel account

    If you do not already have a Vercel account, sign up. It’s free!

  3. Create a Vercel project

    Skip this step if you already have a project started that should use Fauna.

    Use one of the template applications, or start from scratch.

  4. Visit the Fauna integration page

    You can also find the Fauna integration by searching the Integration Marketplace:
    https://vercel.com/integrations?category=databases
    Then click on the Fauna integration.

  5. Add the Fauna integration to your project

    1. Click the Add Integration button.

      The Add Fauna dialog appears:

      The Install Fauna dialog on the Vercel site

    2. Click the Select a Vercel Scope dropdown, and select the scope to use. The lists shows all of your project scopes.

    3. Click the CONTINUE button.

      The dialog updates to show the selected scope, and to ask you to choose which project(s) should include the Fauna integration. You can choose All Projects or Specific Projects by clicking on the respective radio buttons.

      The Install Fauna dialog with project selection, on the Vercel site

      If you choose Specific Projects, a new dropdown field appears. You can search for matching projects by typing into the dropdown’s field. When you click a project, it is added to a list that appears below the dropdown:

      The Install Fauna dialog with a project selected, on the Vercel site

      You can add additional projects that should use the Fauna integration by clicking the dropdown and searching and selecting additional project names. You can click the X button beside a project to remove it from the list.

    4. Once your project selection is complete, click the ADD INTEGRATION button. A popup window appears:

      • If you are not logged in, the Fauna login screen appears. Log in.

      • When you are logged in to Fauna, the Install Vercel/Fauna Connector screen appears:

        The Install Vercel/Fauna Connector screen

        Each project that you have selected appears on this screen asking for permission to access a specific database.

    5. Use the dropdown beside your Vercel project name to choose which database should be connected to your Vercel project, or select Create a New Database which creates a new database named after your Vercel project. When you create a new database, you also need to specify which Region Group the database should be created within.

    6. Click the Install button. It takes a few moments for the Fauna integration to complete its configuration, and then the popup window closes. The integration configuration screen appears:

      The Integration configuration screen, on the Vercel site

      You can manage the integration’s access, or remove the configuration from here.

    7. To confirm that the configuration has been installed, click the Overview button at the top of the page, click the name of one of the projects that you authorized, click the Settings button at the top of the page, then click the Environment Variables button in the left sidebar. When you scroll to the bottom, you should find two environment variables already defined:

      • FAUNA_ADMIN_KEY: This is the secret for an admin key that can access the database associated with your project.

      • FAUNA_DB_DOMAIN: This is the domain of the Region Group containing the associated database.

      Every database connection that your project(s) use to connect to Fauna need to use both environment variables.

That’s it!

You’re all done setting up the Fauna integration for Vercel!

The next step is to build your web application or microservice and include FQL queries using the JavaScript driver.

See the Vercel documentation for help there. Check out the rest of the Fauna documentation for help writing queries and managing your data.

The admin key created by the integration is directly usable only during Vercel builds, or in serverless functions.

If you need to use a Fauna secret in browser-executed code, we recommend that you create a serverless function that can call Login to generate a token. You can then use the token’s secret in client code. You should also consider applying Attribute-based access control (ABAC) roles so that queries executed with the token secret have user-specific privileges.

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!