LoginGet Started

Supabase Integration

Why Supabase?

We selected Supabase as our main database integration for several compelling reasons:

  1. PostgreSQL-based: Supabase is built on top of PostgreSQL, one of the most powerful and reliable open-source relational databases available.

  2. Modern developer experience: Supabase provides an excellent developer experience with features like real-time capabilities, built-in authentication, and a powerful dashboard.

  3. Type safety: Supabase works exceptionally well with TypeScript, aligning perfectly with Pure Dev's TypeScript-first approach.

  4. Scalability: From small projects to enterprise applications, Supabase scales to meet your needs without changing your code.

  5. Comprehensive ecosystem: Beyond just a database, Supabase offers authentication, storage, and real-time subscriptions as part of a cohesive platform.

Getting Started with Supabase

To use Supabase with Pure Dev, you have two options:

Connect to an Existing Supabase Project

If you already have a Supabase project in your organization:

  1. Navigate to the Database settings in Pure Dev
  2. Select "Connect to Existing Supabase Project"
  3. Provide your Supabase project URL and API keys
  4. Pure Dev will automatically test the connection and set up your database interface

Create a New Supabase Project

If you're starting fresh:

  1. Navigate to the Database settings in Pure Dev
  2. Select "Create New Supabase Project"
  3. Follow the guided setup process
  4. Pure Dev will handle the project creation and configuration for you

Connection Security

Pure Dev takes database security seriously. Here's how we handle your database credentials:

Secure Credential Storage

All your database credentials are securely stored in Supabase Vault, a secure secret management system designed specifically for sensitive information like API keys and passwords.

Current Limitations with Supabase Auth

At the time of writing, Supabase does not have the ability to utilize Auth to directly connect to a database without inserting a password. This is a limitation in the current Supabase platform that we're actively working with the Supabase team to address.

In the meantime, Pure Dev securely manages your database credentials using Supabase Vault, ensuring they're encrypted at rest and only accessed when needed for database operations.

How Pure Dev Handles Your Credentials

When you connect Pure Dev to Supabase:

  1. Your database credentials are securely stored in Supabase Vault
  2. Credentials are only transmitted over encrypted connections
  3. No credentials are stored in client-side code or exposed to browsers
  4. Access is managed through secure token-based authentication

Using Supabase in Your Code

Once connected, working with Supabase in Pure Dev is straightforward:

export async function handler(pure: Pure): Promise<PureResponse> {
  const { user } = pure.var;
  const { since } = pure.req.queries;
  const sinceDate = parse(since, "mm/dd/yyyy", new Date());

  const blogs = await pure.db
    .selectFrom("blog.posts")
    .where("user_id", "=", user.id)
    .select(["slug"])
    .where("created_at", ">", sinceDate)
    .execute();

  return pure.json(blogs.map((blog) => blog.slug));
}

Real-time Query Feedback

As you type your database queries, Pure Dev provides:

  • SQL preview showing the exact query being sent
  • Execution time metrics
  • Result preview
  • Type errors if your query doesn't match your schema
  • Performance suggestions

Supabase Features in Pure Dev

Pure Dev gives you access to all core Supabase features:

Data Access

  • CRUD operations with type safety
  • Complex queries with joins and filters
  • Transactions for data integrity
  • Real-time data subscriptions

Authentication

  • User management and authentication
  • Role-based access control
  • Social login providers
  • JWT token handling

Storage

  • File uploads and downloads
  • Public and private buckets
  • Image transformations
  • Access control