1. Create your mongodb account
To start storing data just register a free account on mongodb.com and create a free M0 cluster what you can use as your database!
1. Setting up database
If your M0 cluster is ready, get the your mongodb connection string and paste it to your .env file! Here is an example:

.env.local example

3. Creating your own database schemas
To add a custom data to your database, like products, you need to create a new Model as a database schema with the help of mongoose! Just create a new file in your models directory with a structure of something like this:


1import mongoose, { Schema } from "mongoose";
3  const customerSchema = new Schema(
4    {
5      email: {
6        type: String,
7        required: true,
8        unique: true,
9        match: /^[^s@]+@[^s@]+.[^s@]+$/,
10      },
11    },
12    {
13      timestamps: true,
14    }
15  );
17  const Customer =
18    mongoose.models.Customer || mongoose.model("Customer", customerSchema);
20  export default Customer;  
Congratulations, Champion! You've successfully established your database. Now, it's time to proceed with setting up emails , payments or authentication, if desired!