Self-hosting

You can run 2anki yourself. Here's the short version.

Self-hosting is for tinkerers and contributors. Almost everyone is better off using the hosted service at 2anki.net — same code, no setup, free for the conversion features.

The codebase lives in 2anki/server — a pnpm monorepo with the Express API and the React frontend (the web/ workspace, package name 2anki-web). Free to run for personal or commercial use.

Plan: Free (self-hosted; the hosted-service tiers don't apply when you run your own instance)

System requirements

On Debian/Ubuntu:

sudo apt-get install -y git postgresql libreoffice poppler-utils
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install --lts
npm install -g pnpm

Required env vars

Create .env at the repo root. Real keys live in src/env.example:

PORT=2020
DOMAIN=http://localhost:2020
WORKSPACE_BASE=/tmp/genanki
UPLOAD_BASE=/tmp/genanki-uploads
WEB_BUILD_DIR=./web/build

DATABASE_URL=postgresql://tanki:tanki@localhost:5432/tanki

SECRET=replace-with-a-long-random-string
THE_HASHING_SECRET=replace-with-a-different-long-random-string

SECRET signs session JWTs; THE_HASHING_SECRET encrypts stored Notion tokens. Both must be long random strings before you expose the server publicly. Migrations run automatically on boot via the Knex config.

Optional integrations

Each integration adds a feature. You can run 2anki without any of them — the file-upload conversion path works on its own.

IntegrationEnv varsAdds
Notion OAuthNOTION_CLIENT_ID, NOTION_CLIENT_SECRET, NOTION_REDIRECT_URIConnect Notion + Find pages picker
Anthropic ClaudeANTHROPIC_API_KEYAI flashcard generation from PDFs
StripeSTRIPE_KEY, STRIPE_ENDPOINT_SECRETPaid plans (skip if you're running for yourself)
SendGridSENDGRID_API_KEYTransactional email (password reset, etc.)
DigitalOcean Spaces (S3-compatible)SPACES_ENDPOINT, SPACES_REGION, SPACES_DEFAULT_BUCKET_NAME, plus standard AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEYRemote storage for converted decks (needed for "My Decks" history and sync) and mindmap images. Mindmap image upload requires Spaces — without it, image uploads will fail at the API boundary.

Where to get help

We don't write a full ops manual on purpose — the hosted service is what most users want, and the README plus the code are enough for the tinkerers who don't.