Skip to content

Commit 9119bd9

Browse files
committed
docs: add new blog post 'install-supabase-cli-local-dev.mdx'
1 parent f22be8e commit 9119bd9

File tree

1 file changed

+180
-0
lines changed

1 file changed

+180
-0
lines changed
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
---
2+
title: "How to Install and Use Supabase CLI for Local Development
3+
4+
(55 characters)"
5+
description: "The Supabase CLI simplifies local PostgreSQL development with automated migrations, auth emulation, and AI-powered SQL via Chat2DB. Boost productivity with instant setup, TypeScript support, and real-time debugging tools."
6+
image: "https://i.ibb.co/Pvxc9KvN/f68776e8ca0b.jpg"
7+
category: "Guide"
8+
date: August 5, 2025
9+
---
10+
[![Click to use](/image/blog/bg/chat2db1.png)](https://app.chat2db.ai/)
11+
# How to Install and Use Supabase CLI for Local Development
12+
13+
(55 characters)
14+
15+
import Authors, { Author } from "components/authors";
16+
17+
<Authors date="August 5, 2025">
18+
<Author name="Jing" link="https://chat2db.ai" />
19+
</Authors>
20+
21+
The **Supabase CLI** revolutionizes local development by providing a powerful toolkit for managing **PostgreSQL** databases, authentication, and edge functions. Unlike traditional database management tools like **MySQL Workbench** or **DBeaver**, it offers seamless integration with your development workflow through terminal commands and local emulation. When paired with **[Chat2DB](https://chat2db.ai)**, an AI-powered database management tool, developers gain an intelligent interface for visualizing schemas, generating SQL with natural language, and optimizing queries—making database interactions faster and more intuitive.
22+
23+
<iframe width="800" height="500" src="https://www.youtube.com/embed/ds6fWZrA6lc?si=wR2X-OIG_J3wKOdr" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
24+
25+
---
26+
27+
### **Why Supabase CLI Transforms Local Development**
28+
The **Supabase CLI** eliminates the need for manual database setup by automating local environment configuration. Unlike **DataGrip** or **pgAdmin**, which focus solely on query execution, Supabase CLI integrates database management with authentication (via **GoTrue**), real-time subscriptions, and **PostgreSQL** extensions. Key advantages include:
29+
30+
- **Instant Local Stack Emulation**: Run Supabase locally with `supabase start`, including PostgreSQL, Studio, and Auth.
31+
- **Type-Safe Development**: Auto-generate TypeScript types with `supabase gen types`.
32+
- **Schema Migrations**: Version-controlled migrations via `supabase migration`.
33+
34+
For example, initializing a project is as simple as:
35+
36+
```bash
37+
supabase init
38+
supabase start
39+
```
40+
41+
---
42+
43+
### **Prerequisites for Installing Supabase CLI**
44+
Before installation, ensure your system meets these requirements:
45+
46+
| Requirement | Details |
47+
|------------------|-------------------------------------------------------------------------|
48+
| **Node.js** | v16 or later (install via [nvm](https://github.com/nvm-sh/nvm)) |
49+
| **Docker** | Required for local PostgreSQL emulation ([Installation Guide](https://docs.docker.com/get-docker/)) |
50+
| **Git** | For version-controlled migrations |
51+
52+
Install Node.js and npm:
53+
```bash
54+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
55+
nvm install 16
56+
```
57+
58+
---
59+
60+
### **Step-by-Step Supabase CLI Installation**
61+
Install the CLI globally via npm:
62+
```bash
63+
npm install -g supabase
64+
```
65+
Verify the installation:
66+
```bash
67+
supabase --version
68+
```
69+
Common troubleshooting:
70+
- **Docker not running**: Ensure Docker Desktop is active.
71+
- **Permission errors**: Use `sudo` or fix npm permissions.
72+
73+
---
74+
75+
### **Configuring Your First Local Supabase Project**
76+
Initialize a project and link it to your Supabase dashboard:
77+
```bash
78+
supabase init
79+
supabase login
80+
supabase link --project-ref your-project-id
81+
```
82+
Connect **[Chat2DB](https://chat2db.ai)** to visualize tables. Its AI can generate complex queries from natural language, like:
83+
> _"Show users who signed up last month and their subscription status"_
84+
85+
```sql
86+
-- AI-generated query example
87+
SELECT users.id, users.email, subscriptions.status
88+
FROM users
89+
JOIN subscriptions ON users.id = subscriptions.user_id
90+
WHERE users.created_at >= NOW() - INTERVAL '1 month';
91+
```
92+
93+
---
94+
95+
### **Essential Supabase CLI Commands**
96+
- Start/stop the local stack:
97+
```bash
98+
supabase start
99+
supabase stop
100+
```
101+
- Create and apply migrations:
102+
```bash
103+
supabase migration new create_users_table
104+
supabase db reset
105+
```
106+
107+
---
108+
109+
### **Advanced Workflows: RLS and Edge Functions**
110+
Test **Row-Level Security (RLS)** policies locally:
111+
```sql
112+
-- Enable RLS on a table
113+
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
114+
CREATE POLICY "User can edit own profile" ON profiles
115+
USING (auth.uid() = user_id);
116+
```
117+
118+
Deploy an edge function:
119+
```bash
120+
supabase functions deploy hello-world
121+
```
122+
123+
---
124+
125+
### **Boosting Productivity with Chat2DB**
126+
**[Chat2DB](https://chat2db.ai)** enhances Supabase CLI by:
127+
- **AI-Powered SQL Generation**: Convert plain English to optimized queries.
128+
- **Visual Schema Designer**: Drag-and-drop table relationships.
129+
- **Cross-Platform Support**: Windows, macOS, and Linux.
130+
131+
For example, ask Chat2DB:
132+
> _"Optimize this query for performance"_
133+
134+
```sql
135+
-- Before optimization
136+
SELECT * FROM orders WHERE created_at > '2023-01-01';
137+
138+
-- After AI optimization
139+
SELECT id, total FROM orders WHERE created_at > '2023-01-01' ORDER BY created_at DESC LIMIT 100;
140+
```
141+
142+
---
143+
144+
### **Debugging and Optimization Tips**
145+
- Monitor logs:
146+
```bash
147+
supabase logs
148+
```
149+
- Tune PostgreSQL:
150+
```sql
151+
ALTER SYSTEM SET shared_buffers = '4GB';
152+
```
153+
154+
---
155+
156+
### **FAQ**
157+
1. **Can I use Supabase CLI without Docker?**
158+
No, Docker is required for local PostgreSQL emulation.
159+
160+
2. **How does Chat2DB compare to DBeaver?**
161+
Chat2DB uses AI for query generation and optimization, unlike manual tools.
162+
163+
3. **Is Supabase CLI compatible with Windows?**
164+
Yes, but WSL2 is recommended for best performance.
165+
166+
4. **How to sync local schema with production?**
167+
Use `supabase db pull` to fetch remote schema changes.
168+
169+
5. **Does Chat2DB support real-time collaboration?**
170+
Not yet, but its AI features streamline solo development.
171+
172+
Upgrade your workflow today with **[Chat2DB](https://chat2db.ai)** and Supabase CLI!
173+
174+
## Get Started with Chat2DB Pro
175+
176+
If you're looking for an intuitive, powerful, and AI-driven database management tool, give Chat2DB a try! Whether you're a database administrator, developer, or data analyst, Dify simplifies your work with the power of AI.
177+
178+
Enjoy a 30-day free trial of Chat2DB Pro. Experience all the premium features without any commitment, and see how Chat2DB can revolutionize the way you manage and interact with your databases.
179+
180+
👉 [Start your free trial today](https://chat2db.ai/pricing) and take your database operations to the next level!

0 commit comments

Comments
 (0)