Documentation
Documentation
Introduction

Getting Started

Getting StartedInstallationQuick StartProject Structure

Architecture

Architecture OverviewTech StacktRPC MiddlewareDesign Principles

Patterns

Code Patterns & ConventionsFeature ModulesError HandlingType Safety

Database

DatabaseSchema DefinitionDatabase OperationsMigrationsCaching

API

tRPCProceduresRouterstRPC Proxy Setup
APIsOpenAPIREST Endpoints

Auth & Access

AuthenticationConfigurationOAuth ProvidersRolesSession Management
AuthorizationUser RolesPermissions

Routing & i18n

RoutingDeclarative RoutingNavigation
InternationalizationTranslationsLocale Routing

Components & UI

ComponentsButtonsFormsNavigationDialogs
StylesTailwind CSSThemingTypography

Storage

StorageConfigurationUsageBuckets

Configuration

ConfigurationEnvironment VariablesFeature Flags

Templates

Template GuidesCreate New FeatureCreate New PageCreate Database TableCreate tRPC RouterAdd Translations

Development

DevelopmentCommandsAI AgentsBest Practices

Configuration

Configure storage providers and environment variables

Environment Variables

Add the following environment variables to your .env file:

# S3-Compatible Storage
S3_ACCESS_KEY="your-access-key"
S3_SECRET_KEY="your-secret-key"
S3_BUCKET="your-bucket-name"
S3_REGION="auto"  # Use "auto" for Cloudflare R2
S3_ENDPOINT="https://your-endpoint.r2.cloudflarestorage.com"

Cloudflare R2 Setup

Cloudflare R2 is a cost-effective S3-compatible storage option.

Steps

  1. Create an R2 bucket in your Cloudflare dashboard
  2. Generate API tokens with read/write permissions
  3. Set the endpoint to your R2 bucket URL
S3_ENDPOINT="https://<account-id>.r2.cloudflarestorage.com"
S3_REGION="auto"

AWS S3 Setup

For AWS S3, use the standard configuration:

S3_ENDPOINT=""  # Leave empty for AWS
S3_REGION="us-east-1"

Storage Instance

The storage instance is created in src/lib/storage/server.ts:

import { S3StorageProvider } from "./providers/s3";
import { env } from "@/env/env-server";

export const storage = new S3StorageProvider({
  bucket: env.S3_BUCKET,
  region: env.S3_REGION,
  endpoint: env.S3_ENDPOINT,
  credentials: {
    accessKeyId: env.S3_ACCESS_KEY,
    secretAccessKey: env.S3_SECRET_KEY,
  },
});

Custom Providers

You can implement custom storage providers by implementing the StorageProvider interface:

interface StorageProvider {
  upload(path: string, file: Buffer, contentType: string): Promise<void>;
  download(path: string): Promise<DownloadResult>;
  getSignedUrl(path: string, action: "read" | "write"): Promise<string>;
  delete(path: string): Promise<void>;
  exists(path: string): Promise<boolean>;
}

On this page

Environment Variables
Cloudflare R2 Setup
Steps
AWS S3 Setup
Storage Instance
Custom Providers