Vercel

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 Fauna database. When that is complete, your project can access your Fauna database using FQL to create, retrieve, update, and delete documents.

Add Fauna to your Vercel projects

  1. Create or sign in to your Fauna account

    Go to https://dashboard.fauna.com/register, enter your Email and Password, and click Sign Up.

    Dashboard quick start

    If you already have an account, choose Sign in, enter your Email and Password, and click Sign In.

  2. Sign in to your Vercel account

    If you don’t already have a Vercel account, sign up.

  3. Create a Vercel project

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

    Click Add New and choose Project.

    Use one of the application templates.

  4. Add the Fauna integration to your project

    You can also find the Fauna integration by searching the Integration Marketplace, https://vercel.com/integrations?category=databases, and selecting the Fauna integration.

  5. Click Add Integration to display the Add Fauna dialog.

  6. In the Select a Vercel Scope dropdown, select the scope you want to use.

  7. Click Continue.

  8. Choose which projects should include the Fauna integration by clicking All Projects or Specific Projects.

    If you choose Specific Projects, a dropdown field is displayed where you can search for matching projects. When you click a project, it is added to a list below the dropdown.

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

    Click Continue.

  9. Accept the required permissions and click Add Integration. A popup window displays the project or list of projects you selected in the preceding step, for you to enter a database for the project.

    If the Fauna login screen is displayed, first log in.

    • If you choose Create New Database, enter a database name and choose a Region Group.

    • If you choose Select Existing Database, choose the Region Group. You are then prompted to select a database in that Region Group.

  10. Click Install. It takes a few moments for the Fauna integration to complete its configuration, and then the popup window closes.

    You can manage the integration access or remove the configuration from this page.

    Note that the FAUNA_ADMIN_KEY environment variable is the secret for an admin key that can access the database associated with your project. Every database connection that your projects use to connect to Fauna must use this environment variables.

Considerations

The admin key created by the integration is directly usable only during Vercel builds or in serverless functions. If you want to use a Fauna secret in browser-executed code, you should create a serverless function that can log in to generate a token. See Log in and log out. You can then use the token secret in client code. You should also consider applying roles so queries that execute with the token secret have user-defined privileges. See Create user-defined roles.

Next step

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

See the Vercel documentation for more help.

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!