Skip to main content

Overview

EpiNeko uses Supabase for authentication, database management, and Row Level Security (RLS). The integration provides separate client and server utilities for optimal performance and security.
Supabase utilities are located in src/utils/supabase/ with separate implementations for client-side, server-side, and middleware usage.

Environment Variables

Add these environment variables to your .env.local file:
Both environment variables are required. The application will throw an error if they are missing.

Client-Side Usage

Use the client-side Supabase client for browser-based operations in Client Components.

Creating a Client

Implementation Details

Usage Examples

Server-Side Usage

Use the server-side Supabase client for Server Components, Route Handlers, and Server Actions.

Creating a Server Client

The server client is an async function that must be awaited. It handles cookie management automatically.

Implementation Details

Usage Examples

Middleware Integration

The middleware updates the user session on every request, ensuring authentication state is always fresh.

Implementation

Using in middleware.ts

The middleware automatically refreshes the user session on every request, keeping authentication state synchronized between client and server.

Authentication Patterns

Sign Up

Sign In

Sign Out

Get Current User

Database Operations

Insert

Select

Update

Delete

Type Safety

Generate TypeScript types from your database schema:
Then use them in your code:

Best Practices

Common Issues

Error: Missing Supabase environment variablesEnsure both NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your .env.local file.
Error: Cookie manipulation in Server ComponentsThis warning is expected and can be ignored. The middleware handles session refresh automatically.

Database Schema

View complete database schema

Row Level Security

Learn about RLS policies

Supabase Docs

Official Supabase documentation

Library Service

High-level library operations