How to Connect Supabase PostgreSQL Database in Node.js with Sequelize ORM
Read our latest blog post

Are you looking to connect a PostgreSQL database in your Node.js project using Supabase and Sequelize ORM?
You are in the right place!
In this step-by-step guide, we’ll walk through database connection in Node.js using Supabase PostgreSQL, Sequelize ORM, and how to set up everything easily — even if you are just starting with backend development.
What is Supabase?
Supabase is often called the "open-source alternative to Firebase."
It offers Backend-as-a-Service (BaaS) solutions and provides a free hosted PostgreSQL database with powerful APIs, authentication, storage, and serverless functions.
In this guide, we are only using Supabase for free PostgreSQL hosting.
Supabase is perfect for MERN Stack learners and developers in Nepal who want real-world backend experience without worrying about complex setups.
What is Sequelize?
Sequelize is one of the most popular ORMs (Object-Relational Mappers) for Node.js.
It allows you to easily interact with SQL databases like PostgreSQL using JavaScript instead of writing complex SQL queries manually.
Step 1: Set Up Your Database on Supabase
-
Go to supabase.com
-
Sign up with your GitHub account (recommended) or Google account.
-
Create an organization and follow below video steps
Note: Keep this connection string secure and avoid sharing it publicly.
Step 2: Set Up Your Node.js Project
Inside your Node.js (Express.js) project:
Install Required Packages
Open your terminal and run:
npm install sequelize pg
-
sequelizeis the ORM -
pgis the official PostgreSQL driver for Node.js
Step 3: Connect to Supabase PostgreSQL Database
Inside your project, create a folder called database and inside that, a file named connection.js.
database/connection.js
const { Sequelize } = require("sequelize");// Replace below with your Supabase Database Connection String
const sequelize = new Sequelize("YourSupabaseDatabaseConnectionStringHere");sequelize.authenticate()
.then(() => {
console.log("Database connected successfully!");
})
.catch((err) => {
console.error("Database connection error:", err);
});module.exports = sequelize;
Step 4: Connect Database in Entry File (e.g., app.js)
app.js
const express = require("express");
const app = express();// Connect to the database
require("./database/connection");app.listen(4000, () => {
console.log("Server running on port 4000 🚀");
});
That’s it! 🎯
Now, run your project:
node app.js
You will see:
Database connected successfully!
Server running on port 4000 🚀
Best Practices:
✅ Always store your Database URL inside an .env file instead of hardcoding it.
✅ Avoid using special characters in database passwords.
✅ Never expose your .env file publicly (use .gitignore).
Example .env file:
DATABASE_URL=your_connection_string_here
and in your connection.js file, use:
require('dotenv').config();
const sequelize = new Sequelize(process.env.DATABASE_URL);
Conclusion
Now you have successfully connected your Supabase PostgreSQL database to your Node.js Express project using Sequelize ORM!
This is one of the most important skills you need if you are planning to learn backend development, Node.js, or MERN Stack professionally.
Learn MERN Stack in Nepal 🇳🇵
If you are looking for the Best MERN Stack Course in Nepal,
or want to master Node.js, Express.js, MongoDB, PostgreSQL, React.js with live projects,
then check out Digital Pathshala's MERN Stack Course —
👉 designed specially for Nepali students at affordable fees!
Course Link : Click here
✅ Project-based learning
✅ Job placement assistance
✅ Live support and community access
✅ Internship and real-world projects
Build your career in tech starting today!
Manish Basnet
Digital Pathshala is Nepal's leading IT company in Itahari, dedicated to providing world-class IT education and innovative software solutions. With 12,000+ successful graduates and 15+ successful projects, we are transforming Nepal's digital landscape through quality education and cutting-edge technology.
Ready to Start Your IT Journey?
Join thousands of successful students who have transformed their careers through our comprehensive IT education programs.