← Back to Documentation
Database Setup

MongoDB Integration Guide

To store user transactions, order details, and customer data efficiently, you can set up MongoDB, a NoSQL database known for scalability and flexibility.

Stripe Logo
Get a MongoDB Connection URL and Set Up a DatabaseMongodb
1Go to MongoDB Atlas and sign up (or log in if you already have an account https://www.mongodb.com/).
2Click 'Create a Cluster' and choose the free tier (Shared).
2Select a cloud provider and region (closest to your users).
3Click 'Create Cluster' (it may take a few minutes to set up).

Create a Database & Collection

1In the MongoDB Atlas Dashboard, go to Database Browse Collections.
2Click 'Add My Own Data' and enter a Database Name and Collection Name (e.g., your product name ).
2Click Create.
3Click 'Create Cluster' (it may take a few minutes to set up).
Get Your Connection URL
1Go to Database Connect and choose 'Connect your application'.
2Select 'Node.js' as the driver and choose the latest version.
2Copy the provided connection string, which will look like this:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database?retryWrites=true&w=majority
Replace Username Your MongoDB username Password → Your MongoDB password Dbname → Your database name

4. Store It in Your .env.local File

  1. Add inside .env.local file in your Next.js project root
  2. MONGODB_URI=mongodb+srv://yourUsername:yourPassword@cluster0.mongodb.net/yourDatabase?retryWrites=true&w=majority
  3. Configure network access (IP whitelist)
  4. Get your connection string

Test the API

Now MongoDB is fully set up and ready to use in your Next.js project! 🚀

npm run dev

Alternative Database

Supabase Integration Guide

Supabase Logo
Setting Up Supabase ProjectSetup
1Visit supabase.com and sign up for an account
2Click New Project and choose your organization
3Set up your database password and choose a region
Project Configuration
1Go to Project Settings → API to find your credentials
2Copy your Project URL and anon/public API key
# .env.local SUPABASE_URL=your-project-url SUPABASE_ANON_KEY=your-anon-key
Upcoming