Database
Learn how to set up your database with popular providers for your Indie Kit project
Setting Up Your Database ⚡️
Indie Kit supports multiple database providers. Choose the one that best fits your needs! 🚀
Setting up Neon (PostgreSQL) 🎯
-
Create a Neon Account 👤
- Go to neon.tech
- Click "Sign Up" and create your account
- You can use GitHub for quick signup
-
Create a New Project 📦
- Click "New Project" in your Neon dashboard
- Choose a name for your project
- Select the region closest to your users
- Click "Create Project"
-
Get Your Connection String 🔗
# Your connection string will look like this: postgresql://[user]:[password]@[neon-host]/[database]
- Find the connection string in your project dashboard
- Make sure to use the full connection string with your credentials
💡 Pro Tip
Neon offers a generous free tier perfect for development and small projects. You can always upgrade as your project grows!
Setting up Supabase (PostgreSQL) 🎯
-
Create a Supabase Account 👤
- Go to supabase.com
- Click "Start your project"
- Sign up with GitHub for easier setup
-
Create a New Project 📦
- Click "New Project" in your dashboard
- Fill in your project details
- Choose a region and database password
- Wait for project creation (usually 1-2 minutes)
-
Get Your Connection String 🔗
- Click "Connect"
postgresql://postgres:[YOUR-PASSWORD]@db.[project-ref].supabase.co:5432/postgres
💡 Pro Tip
Supabase provides additional features like Auth, Storage, and Edge Functions! Perfect if you need a full backend platform.
Setting up PlanetScale (MySQL) 🎯
-
Create a PlanetScale Account 👤
- Visit planetscale.com
- Click "Sign Up"
- Create your account (GitHub recommended)
-
Create a New Database 📦
- Click "Create a new database"
- Choose a name and region
- Select "Hobby" plan for development
- Click "Create database"
-
Get Your Connection String 🔗
- Click "Connect"
- Choose "Connect with" > "Prisma"
- Copy the connection string
mysql://[username]:[password]@[host]/[database]?sslaccept=strict
💡 Pro Tip
PlanetScale's branching feature is great for schema changes! Perfect for teams with complex database workflows.
Configuring Your Project 🛠️
- Set Up Environment Variables 📝
- Open your
.env
file - Add your database connection string:
DATABASE_URL="your-connection-string-here"
- Open your
Syncing Database Schema 🔄
-
Push Schema to Database 🚀
npx drizzle-kit push
This command will:
- Connect to your database
- Create all necessary tables
- Sync your schema changes
-
Verify Setup ✅
npm run dev
- Start your development server
- Your app should now connect to the database
- Check the console for any connection messages
Note: Indie kit uses "JWT" session strategy by default, though you can use "Database" session strategy if you want to. Read more about it here.
If you want to use your own hosted postgresql database, you may need to set following in db.ts
file.
import { drizzle } from 'drizzle-orm/postgres-js';
export const db = drizzle(process.env.DATABASE_URL!)
Troubleshooting 🔍
If you encounter any issues:
-
Connection Issues 🌐
- Verify your connection string is correct
- Check if your IP is allowed in database settings
- Ensure your database user has proper permissions
-
Schema Sync Issues 📊
- Check if
drizzle.config.ts
is properly configured - Verify your schema files are correctly exported
- Look for any console errors during schema push
- Check if
Next Steps 🎯
- Set up your database indexes for better performance
- Configure database pooling if needed
- Consider setting up database backups
- Explore your database provider's dashboard for monitoring
Now your Indie Kit app is connected to your chosen database! Ready to start building? 🚀