Supabase - Open Source Firebase Alternative
Supabase is an open-source Firebase alternative that provides PostgreSQL database, authentication, storage, and real-time subscriptions.
GitHub
https://github.com/supabase/supabase
What is Supabase?
Supabase is a Backend-as-a-Service (BaaS) that gives you:
Key Features
1. PostgreSQL Database
2. Authentication
3. Real-time
4. Storage
Getting Started
1. Create Project
Go to https://supabase.com and create a free project.
2. Initialize in Your Code
ash
npm install @supabase/supabase-js
javascript
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
'YOUR_SUPABASE_URL',
'YOUR_SUPABASE_KEY'
)
3. Query Data
javascript
// Fetch data
const { data, error } = await supabase
.from('users')
.select('*')
// Insert data
const { data, error } = await supabase
.from('users')
.insert([{ name: 'John', email: 'john@example.com' }])
// Update data
const { data, error } = await supabase
.from('users')
.update({ name: 'Jane' })
.eq('id', 1)
4. Real-time Subscriptions
javascript
const subscription = supabase
.from('users')
.on('INSERT', payload => {
console.log('New user:', payload.new)
})
.subscribe()
5. Authentication
javascript
// Sign up
const { data, error } = await supabase.auth.signUp({
email: 'user@example.com',
password: 'password123'
})
// Sign in
const { data, error } = await supabase.auth.signInWithPassword({
email: 'user@example.com',
password: 'password123'
})
Advantages Over Firebase
| Feature | Firebase | Supabase |
|---------|----------|----------|
| Database | NoSQL | PostgreSQL |
| Query Language | Custom | SQL |
| Pricing | Usage-based | Generous free tier |
| Open Source | No | Yes |
| Self-hosting | No | Yes |
| Export Data | Limited | Full access |
Free Tier
Why Supabase?
Use Cases
Summary
Supabase gives you the simplicity of Firebase with the power of PostgreSQL. If you're building a web or mobile application, Supabase is an excellent choice for your backend needs.
Rating: 猸愨瓙猸愨瓙猸?
Best for: Web apps, mobile apps, SaaS
Learning curve: 猸愨瓙猸?
Free tier: Yes
💬 评论区 (0)
暂无评论,快来抢沙发吧!