FaunaDB Integration for Vercel

The FaunaDB Integration for Vercel makes it easy to use FaunaDB as the database for your Vercel sites and serverless 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 Vercel, 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.

How to use the FaunaDB Integration for Vercel

It only takes a few minutes to get setup. There are three phases:

FaunaDB setup

  1. Sign in to your FaunaDB account

  2. Create a database for all of your Vercel projects.

    Skip this step if you have performed it previously.

    • Click the New Database button,

    • Enter vercel as the database name,

    • Click Save.

  3. Create an admin key for the Vercel database

    Skip this step if you have performed it previously.

    • Click Security in the left navigation bar,

    • Click New Key,

    • Ensure that the Database field is set to Vercel,

    • Ensure that the Role field is set to Admin,

    • Enter Vercel into the Key Name field,

    • Click Save,

    • Copy the displayed secret, and store it somewhere safe. The secret is only shown once!

  4. Create a project-specific database for a Vercel project.

    • Click DB Overview in the left navigation bar,

    • Beside the "Child databases" heading, click New Database,

    • Enter faunadb-vercel-sample-app as the database name,

    • Click the "Pre-populate with demo data" checkbox,

    • Click Save.

Vercel setup

  1. Sign up for a Vercel account

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

  2. Install the Vercel CLI

    In a terminal window, run these commands:

    npm i -g now
    now login
  3. Add the FaunaDB integration to your Vercel account

    • Visit https://vercel.com/integrations/faunadb,

    • Click Add,

    • Click which Vercel account to use,

    • Click Add,

    • In the Admin Key Secret field, paste the key that you created in step 3, in the FaunaDB setup procedure,

    • Click Save Secret,

    • Click the Select a project select box,

    • Enter your project name (faunadb-vercel-sample-app) and press Return,

    • Under Link To Project, click the faunadb-vercel-sample-app button.

App setup

  1. Clone and deploy the sample app

    In a terminal, run these commands:

    git clone https://github.com/fauna/faunadb-zeit-sample-app
    cd faunadb-zeit-sample-app
    now --prod
  2. Navigate to your project’s web page

    The URL is displayed after the previous command completes. It is also copied for you, so you can open a new browser tab/window, and paste the URL into the browser’s location bar.

    You should see the same list of collections that are displayed in the FaunaDB Console.

That’s it!

You’re all done setting up the FaunaDB Integration for Vercel.

The next step is to build your web application or microservice.

See the Vercel 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! documentation@fauna.com

Thank you for your feedback!