Indie Kit DocsIndie Kit Docs
Setup

Setting Up Your 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) 🎯

  1. Create a Neon Account 👤

    • Go to neon.tech
    • Click "Sign Up" and create your account
    • You can use GitHub for quick signup
  2. 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"
  3. 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!

Configuring Your Project 🛠️

  1. Set Up Environment Variables 📝
    • Open your .env file
    • Add your database connection string:
    DATABASE_URL="your-connection-string-here"

Syncing Database Schema 🔄

  1. Push Schema to Database 🚀

    npx drizzle-kit push

    This command will:

    • Connect to your database
    • Create all necessary tables
    • Sync your schema changes
  2. 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:

  1. Connection Issues 🌐

    • Verify your connection string is correct
    • Check if your IP is allowed in database settings
    • Ensure your database user has proper permissions
  2. 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

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? 🚀

On this page