Get Supabase running and interact with your first database in under 8 minutes. This guide covers creating a project, installing the client library, and performing basic CRUD operations.
Prerequisites
-
Supabase Account Free account at supabase.com
-
Node.js Version 18 or higher
-
Package Manager npm, yarn, or pnpm
Create a Supabase Project
Create a Supabase Project
~2 minOption A: Using the Dashboard (Recommended for beginners)
Create a new project at supabase.com/dashboard/new →- Click “New Project”
- Choose your organization
- Enter a project name and database password
- Select a region close to your users
- Click “Create new project”
Save your database password securely - you'll need it for direct database connections.
Option B: Using the Supabase CLI
# Install Supabase CLI
npm install -g supabase
Login to Supabase
supabase login
Create a new project (interactive)
supabase projects create my-project –org-id your-org-id
Find your org-id in your Supabase dashboard URL: supabase.com/dashboard/org/[org-id]
Install Supabase Client
Install Supabase Client
~1 minInstall the Supabase JavaScript client library:
npm install @supabase/supabase-js
added 1 package in 2s
Using other package managers:
# Yarn
yarn add @supabase/supabase-js
pnpm
pnpm add @supabase/supabase-js
Initialize and Connect
Initialize and Connect
~1 minGet your project credentials from the Supabase dashboard:
Find your API keys in Project Settings > API →Create a new file to initialize the Supabase client:
// supabase.ts
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = ‘https://your-project-ref.supabase.co’
const supabaseAnonKey = ‘your-anon-key’
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
Never expose your service_role key in client-side code. Use the anon key for browser applications.
Test the connection:
// test-connection.ts
import { supabase } from './supabase'
async function testConnection() {
const { data, error } = await supabase.from(’_test’).select(’*’).limit(1)
if (error && error.code === ‘42P01’) {
console.log(‘Connected successfully! (Table does not exist yet)’)
} else if (error) {
console.error(‘Connection error:’, error.message)
} else {
console.log(‘Connected successfully!’)
}
}
testConnection()
Your client is now configured and ready to interact with your database.
Create a Table
Create a Table
~2 minOption A: Using the Dashboard (Recommended)
- Go to the Table Editor in your Supabase dashboard
- Click “New Table”
- Create a
todostable with these columns:
| Name | Type | Default | Primary |
|---|---|---|---|
| id | int8 | - | Yes (auto) |
| title | text | - | No |
| completed | bool | false | No |
| created_at | timestamptz | now() | No |
Option B: Using SQL
Go to the SQL Editor and run:
CREATE TABLE todos (
id BIGSERIAL PRIMARY KEY,
title TEXT NOT NULL,
completed BOOLEAN DEFAULT FALSE,
created_at TIMESTAMPTZ DEFAULT NOW()
);
– Enable Row Level Security (recommended)
ALTER TABLE todos ENABLE ROW LEVEL SECURITY;
– Create a policy to allow all operations (for testing)
CREATE POLICY “Allow all operations” ON todos
FOR ALL
USING (true)
WITH CHECK (true);
Success. No rows returned
Row Level Security (RLS) is enabled by default on new tables. The policy above allows all operations for testing purposes.
Insert and Query Data
Insert and Query Data
~2 minInsert data:
import { supabase } from './supabase'
// Insert a single row
const { data, error } = await supabase
.from(’todos’)
.insert({ title: ‘Learn Supabase’ })
.select()
console.log(‘Inserted:’, data)
Inserted: [
{
id: 1,
title: 'Learn Supabase',
completed: false,
created_at: '2026-02-03T10:30:00.000Z'
}
]
Insert multiple rows:
const { data, error } = await supabase
.from('todos')
.insert([
{ title: 'Build an app' },
{ title: 'Deploy to production' }
])
.select()
console.log(‘Inserted:’, data)
Query data:
// Fetch all todos
const { data: todos, error } = await supabase
.from('todos')
.select('*')
.order('created_at', { ascending: false })
console.log(‘All todos:’, todos)
All todos: [
{ id: 3, title: 'Deploy to production', completed: false, ... },
{ id: 2, title: 'Build an app', completed: false, ... },
{ id: 1, title: 'Learn Supabase', completed: false, ... }
]
Update data:
const { data, error } = await supabase
.from('todos')
.update({ completed: true })
.eq('id', 1)
.select()
console.log(‘Updated:’, data)
Delete data:
const { error } = await supabase
.from('todos')
.delete()
.eq('id', 1)
if (!error) console.log(‘Deleted successfully’)
You've created a table and performed full CRUD operations. Explore authentication, realtime subscriptions, and storage next.