Skip to Content
Texfolia Docs

Local development

Local development runs Postgres, MinIO, and the compiler in Docker Compose. Vite runs the Worker with Wrangler's Durable Object emulation. Production uses Neon and Cloudflare R2. MinIO serves the same S3 API as R2, so the compiler and the app read and write storage the same way in both. Production resources and secrets belong only in the Cloudflare deployment configuration and production secret store. Never put production database URLs or secrets in local environment files.

Install Bun 1.4.5, Docker with Compose, and the Stripe CLI. Start Docker before running the app. Postgres, the Workers runtime, compiler storage, and email delivery run locally. API integrations use your configured credentials.

To install the pinned Bun version with npm, run npm install -g bun@1.4.5.

git clone https://github.com/texfolia/texfolia.git
cd texfolia
bun install
test -e apps/web/.env || cp apps/web/.env.example apps/web/.env
test -e packages/db/.env || cp packages/db/.env.example packages/db/.env

Generate a secret with openssl rand -base64 32 and set BETTER_AUTH_SECRET in apps/web/.env to the result.

Start the local services, then apply the schema.

bun run infra:start
bun run db:push

Compose creates the sources and compilation buckets when it starts. To inspect the buckets, open the MinIO console and sign in with the S3 credentials from compose.yaml.

The env examples match the local Compose services. If you customize the compiler token or bucket names, set them in apps/compiler/.env and apps/web/.env.

In apps/web/.env, configure a Stripe sandbox STRIPE_SECRET_KEY and recurring STRIPE_PRO_PRICE_ID and STRIPE_TEAM_PRICE_ID, your Turnstile site key and secret, and credentials for the OAuth providers you use. Secrets are required configuration; the app does not generate fallback credentials or replace Stripe with a mock.

Run bun run --cwd apps/web billing:setup to create or reuse the $15 Pro and $20/user Team monthly prices, then copy its price IDs into apps/web/.env. See subscription billing setup and verification for shared billing, portal configuration, and sandbox checks.

Keep the database settings in packages/db/.env and apps/web/.env pointed at the local Postgres database. The examples use the postgres database on localhost:5432. The compiler connects to it through the Compose network.

Local database, storage, compiler, and engine URLs must use localhost, 127.0.0.1, or [::1]. Startup rejects cloud URLs and CLOUDFLARE_ENV overrides. Vite disables remote bindings. db:push and auth:schema also require a local database. Keep local integration credentials separate from production credentials.

Upgrade a local Postgres 18 database

Compose uses PostgreSQL 19 Alpine with the existing pgdata volume. PostgreSQL 19 needs its own data directory. Dump the database while the PostgreSQL 18 container is still running.

docker compose exec -T db sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > texfolia-pg18.dump

After the dump succeeds, stop the local services. Move the stopped 18 cluster aside inside the volume so the 19 image can initialize its own directory.

bun run infra:stop
docker compose run --rm --no-deps --entrypoint sh db \
  -ec 'cd /var/lib/postgresql/18 && test ! -e docker.pg18 && mv docker docker.pg18'
bun run infra:start
docker compose exec -T db pg_restore --exit-on-error --single-transaction --no-owner --no-acl -U postgres -d postgres < texfolia-pg18.dump
bun run db:push

The original cluster stays in pgdata at 18/docker.pg18.

Forward Stripe webhooks

Log the Stripe CLI into the same sandbox as the app's Stripe API key. In a separate terminal, run:

stripe login
stripe listen --forward-to localhost:3000/api/auth/stripe/webhook

The listener forwards events to localhost:3000/api/auth/stripe/webhook. Copy its signing secret into STRIPE_WEBHOOK_SECRET in apps/web/.env, then start or restart the app. Keep the listener running while testing subscriptions. Use the listener's signing secret for local forwarding, rather than a dashboard webhook endpoint's secret. This follows Better Auth's local webhook setup.

Start the app

Start every app:

bun dev

This waits for Postgres, MinIO, and the compiler, then starts the web app and docs through Turbo.

AppCommandURL
Product appbun run dev:weblocalhost:3000
Documentationbun run dev:docslocalhost:4322
Compilerbun dev:compilerhttp://localhost:8080

The first run pulls texlive/texlive:latest-medium and builds the Go compiler in Docker. To rebuild the image after changing compiler code, run docker compose up --build --wait compiler.

Press Ctrl+C to stop the apps. Stop the Compose services separately.

bun run infra:stop

Postgres and MinIO data persist in their Compose volumes.

Change the schema

bun run dev never changes the schema. Run bun run db:push after changing the schema.

Local services

Cloudflare simulates the email binding locally and logs the file containing each verification, sign-in code, or invitation email. You can also inspect sent messages in Local Explorer. Auth uses the same plugins and login flow in every environment, including Stripe customer setup and webhook signature verification.

The web app reads env.HYPERDRIVE.connectionString in both environments. Local development uses CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE from apps/web/.env. Compiler requests use loopback HTTP locally and a service binding on Cloudflare. The compiler stores no jobs or PDFs.

See the database guide for standalone schema operations and integration checks. For deployed environments, follow Set up Neon and Hyperdrive.

Compile your first PDF

  1. Open localhost:3000 and sign in.
  2. Create a project and paste the example below into main.tex.
  3. Press Cmd/Ctrl+S or select File → Save & compile, then open the PDF under out in Files.
\documentclass{article}
\begin{document}
Hello from Texfolia!
\end{document}

On this page