Initialize and Configure a Fauna Database inside a Next.js project with fauna-shell

Shadid Haque
InstructorShadid Haque
Share this video with your friends

Social Share Links

Send Tweet
Published 5 months ago
Updated 2 months ago

The first step is to install and configure our database that will be backing our Next.js application. We'll be using Fauna so we head over to the Fauna website and create a database.

Back in our terminal we will install fauna-shell so we can interact and manage our database from within our project. After some initializing steps from the CLI we'll be set up to build the app out.

[00:00] We're gonna be using fauna as our database for this project. So let's go to fauna.com, and let's go ahead and log in. Once you logged in, you're presented with a dashboard where you can see all the databases you have already created. So I'm gonna go ahead and create a new database. So I'm just gonna select create database. Here, I'm gonna give my [00:20] database a name. I'm gonna call it my new app. Next, I'm gonna select region group. I'm gonna select US for this database. I'm going to disable the backups for now and I am also going to disable the static typing. Now let's go ahead create this database. [00:40] Now once the database is created, we can go and search for it and we will select the database and it will open up in the explorer. Now here from the UI we can create collections, we can add and delete documents to the collection, we can also create functions and roles, but for this course we're gonna do all that through the fauna [01:00] cli and the fauna schema. So back in our terminal, let's go ahead and install the fauna shell globally by running npmidashgfauna shell. Fauna shell is a command line interface for fauna that lets you manage your databases from within your command line. Next, I'm going to run the fauna cloud login [01:21] and it's going to ask me for an endpoint and I'm going to keep the default which is cloud And then I'm going to provide my email address and my password that I use for my phone or cloud. And then it's going to ask me for a region. I'm going to select cloud us. [01:44] And now our configuration is updated. And this logs me into my FaunaCloud account from the command line. Next I'm going to run fauna project init to initialize a new fauna project within this codebase. I'll accept the default directory and then I'm gonna give my environment a [02:04] name. We'll select cloud us as our default endpoint because that's where our database is located And then we're gonna select a database for this project. In this case, it's gonna be my new app database. And now our project is configured to use fauna.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today