AFFiNE: Self-Host an Open-Source Notion and Miro Alternative with Docker Compose
AFFiNE merges documents, an infinite whiteboard and databases into one local-first workspace. Here's what it can do, how the self-hosted Community Edition is licensed, and how to run it with Docker Compose.
Most of us have tried to cram our lives into Notion at some point: meeting notes, a reading list, a project board, maybe a mood board for the next trip. It works, until you remember that every word lives on someone else's server. And the moment you want to sketch something, you open Miro or Excalidraw in another tab.
AFFiNE wants to be both tools at once, and it wants you to own the data. It is one of the projects on GitHub's daily trending list today, sits at roughly 75,900 stars, and its self-hosting docs were updated this week. Reason enough to take a closer look and run it at home.
What is AFFiNE?
AFFiNE (pronounced like the word affine) is an open-source workspace by the company Toeverything. Its pitch is simple: docs, whiteboards and tables are "hyper-merged". Any page can be viewed as a classic document (Page mode) or opened on an infinite canvas (Edgeless mode), where the same blocks sit next to sticky notes, shapes, embedded web pages and slides.
The editor is built on the team's own BlockSuite framework. Sync is based on CRDTs (Yjs and the Rust implementation y-octo), which is what makes the app local-first: your workspace lives on your device, works offline and syncs to a server when one is available. That server can be AFFiNE Cloud or, and that's why we're here, your own box.
There are clients for Windows, macOS, Linux, iOS, Android and the web. The desktop apps can connect to a self-hosted server, so you don't have to live in a browser tab.

Key features
- Docs and whiteboard in one place. Switch any page between Page and Edgeless mode. On the canvas you can mix rich text, sticky notes, shapes, connectors, frames, images, embeds and linked pages.
- Databases inside pages. Insert table or kanban views with properties such as status, owner, progress and dates, and filter or sort them. Good enough for a task tracker or a reading log.
- Real-time collaboration. Multiple people can edit the same doc or board, with live cursors, via the sync server.
- Local-first and offline. Data is stored on your disk first and synced later, so a server outage doesn't lock you out of your notes.
- Self-hosted Admin Panel. Under
/adminyou manage users, server settings, storage, SMTP and OAuth. - Login with Google, GitHub or any OIDC provider. Handy if you already run an identity provider such as Pocket ID. The callback URL is
https://your-domain/oauth/callback. - S3-compatible or Cloudflare R2 blob storage instead of the local filesystem, if you prefer.
- Optional AI with your own keys (BYOK). Workspace owners can add API keys for OpenAI, Anthropic, Gemini or FAL. The feature is marked experimental and may need to be reconfigured after upgrades.
- Templates and imports. A template gallery, plus importers (the latest release, for example, improves the OneNote importer).

A word on the license
This is worth reading before you commit. The repository's top-level LICENSE is split:
- Everything outside
packages/backendandpackages/common/nativeis under the MIT license. - Code in those two directories falls under a separate license file in
packages/backend/server/LICENSE. That file is an Enterprise Edition (EE) license, but it states that it only applies to parts that are not distributed as part of the AFFiNE Community Edition.
The README sums it up as: AFFiNE Community Edition is free to self-host under the MIT license, and an Enterprise Edition with features such as rebranding, SSO, advanced admin and audit tools "is yet to be published". So for a homelab, the self-hosted server is free to run. Just be aware this is an open-core company, and some limits apply (see below).
Why self-host it?
- Your notes stay on your hardware. Postgres and the uploaded files sit in a directory you control and back up.
- One tool instead of three. If you bounce between a notes app, a whiteboard and a spreadsheet-style tracker, AFFiNE covers all three in one workspace.
- Small teams are covered for free. Self-hosted workspaces get up to 10 seats each, which is plenty for a household, a club or a small team.
- Native apps that point at your server. Unlike many self-hosted wikis, you get polished desktop and mobile clients.
Requirements
According to the official requirements page:
- About 1.5 GB of disk for the server itself, plus room for data (the AFFiNE team measured roughly 100 MB of Postgres growth per 1,000 docs).
- At least 4 CPU cores recommended.
- 2 GB RAM for basic use, 4 GB if you have docs with more than 10,000 words. Merging a doc with many edits can briefly peak at around 1 GB.
- Docker with Docker Compose v2.
It's not the lightest app you'll ever host, so a Raspberry Pi with 1 GB is not the right target.
Install AFFiNE with Docker Compose
The current stable release is v0.27.4, and it changed the official Compose template: new installs no longer need an .env file. Runtime settings live in config/config.json instead.
1. Create a directory
mkdir affine && cd affine
mkdir -p config
2. Download the Compose file and the example config
curl -L -o docker-compose.yml \
https://github.com/toeverything/AFFiNE/releases/latest/download/docker-compose.yml
curl -L -o config/config.json \
https://github.com/toeverything/AFFiNE/releases/latest/download/config.json.example
At the time of writing, the downloaded file looks like this:
name: affine
services:
affine:
image: ghcr.io/toeverything/affine:stable
container_name: affine_server
ports:
- '3010:3010'
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
affine_migration:
condition: service_completed_successfully
volumes:
- ./data/storage:/root/.affine/storage
- ./config:/root/.affine/config
environment:
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://affine@postgres:5432/affine
- AFFINE_INDEXER_ENABLED=false
restart: unless-stopped
affine_migration:
image: ghcr.io/toeverything/affine:stable
container_name: affine_migration_job
volumes:
- ./data/storage:/root/.affine/storage
- ./config:/root/.affine/config
command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js']
environment:
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://affine@postgres:5432/affine
- AFFINE_INDEXER_ENABLED=false
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
redis:
image: redis
container_name: affine_redis
healthcheck:
test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
postgres:
image: pgvector/pgvector:pg16
container_name: affine_postgres
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: affine
POSTGRES_DB: affine
POSTGRES_INITDB_ARGS: '--data-checksums'
POSTGRES_HOST_AUTH_METHOD: trust
healthcheck:
test: ['CMD', 'pg_isready', '-U', 'affine', '-d', 'affine']
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
Four services: the AFFiNE server on port 3010, a one-shot migration job that prepares the database before every start, Redis (required for cache, background jobs and sync) and Postgres 16 with pgvector (needed for the AI features). Data ends up in ./data/postgres and ./data/storage, settings in ./config.
A note on POSTGRES_HOST_AUTH_METHOD: trust: the database has no password, which the docs justify because neither Postgres nor Redis publishes a port and only the private Compose network can reach them. Keep it that way. Don't add a ports: entry for Postgres and don't attach other containers to that network unless you switch to password authentication first.
3. Set your URL in config/config.json
{
"$schema": "https://github.com/toeverything/affine/releases/latest/download/config.schema.json",
"server": {
"name": "AFFiNE Self-hosted",
"externalUrl": "https://affine.example.com"
},
"copilot": {
"enabled": true,
"byok": {
"enabled": true
}
}
}
server.externalUrl must be the exact URL your users will open, because AFFiNE uses it to build invite and share links. For a quick local test, leave it at http://localhost:3010. If you don't want AI at all, set copilot.enabled to false. The example file from the release also contains "allowCustomEndpoint": true under byok. Only keep it if you actually want workspace owners to point AI requests at custom endpoints.
4. Start it
docker compose up -d
docker compose ps
The affine_migration_job container should exit successfully while the other three keep running. If something hangs, check:
docker compose logs --tail=200 affine affine_migration
5. Create the admin account
Open http://your-server:3010 (or your external URL). On first visit you're asked to create the initial administrator. Afterwards, /admin/settings is where you configure server name, SMTP for email invites, OAuth providers and storage.
In the desktop app, add your server via the workspace list in the top-left corner and log in with your new account.

Configuration tips
Put it behind a reverse proxy with HTTPS. AFFiNE's sync runs over WebSockets, so your proxy has to pass Upgrade headers through. Caddy does this out of the box:
affine.example.com {
reverse_proxy http://127.0.0.1:3010
}
With nginx, set proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade";, and raise client_max_body_size (the docs use 100m) so uploads don't fail. Traefik handles WebSockets automatically. Once it works, bind the port to localhost ('127.0.0.1:3010:3010') so nobody bypasses the proxy.
Pin the version. stable is convenient, but the upgrade guide explicitly warns against blind upgrades. The image is also published with version tags, so ghcr.io/toeverything/affine:0.27.4 works for both the server and the migration service. Bump it on purpose after reading the release notes.
Mind client and server versions. Since 0.27, desktop and mobile clients only sync with servers on 0.27 or newer. Update the server before or together with your devices.
Back up all three parts. A database dump alone isn't enough, because uploaded images and attachments live in ./data/storage. The official Postgres backup reads user and database name from the running container:
docker exec affine_postgres sh -c \
'pg_dump --format=custom --file=/tmp/affine.backup --username="$POSTGRES_USER" "$POSTGRES_DB"'
docker cp affine_postgres:/tmp/affine.backup ./affine.backup
Store that file together with a copy of ./data/storage, ./config and your docker-compose.yml, and test a restore at least once.
Upgrading an older install? If you set up AFFiNE before 0.27.4 using an .env file, do not just download the new Compose file and start it. The paths and the database credentials changed, and you could end up with an empty database and a "create admin" screen. Follow the upgrade guide and either carry your old paths and credentials into the new file, or restore a backup into the new layout.
Honest limitations
- 10 seats per workspace. More members require a paid Team plan or an installable license from AFFiNE.
- Blob quota. The docs say self-hosted instances are planned to get unlimited blob storage and file size, but that work isn't finished yet.
- Resource hungry. With Postgres, Redis and a Node.js server, plan for 2 to 4 GB of RAM.
- Server-side full-text search is extra work. It needs a separate Manticore Search indexer container, and the indexer guide still refers to the older
.env-based setup. - AI means external providers. BYOK sends content to OpenAI, Anthropic, Gemini or FAL unless you configure a custom endpoint, and the feature is experimental.
- Pre-1.0 software. Version 0.27 brought breaking changes to configuration and client compatibility. Expect more of those.
- Open-core licensing. The server code is split between MIT and an EE license file. The Community Edition is free to self-host, but keep an eye on how the project evolves.
How does it compare?
If you mainly want a structured knowledge base, Trilium Notes gives you a deep note hierarchy and scripting with far fewer resources, but no whiteboard or real-time team editing. Classic wikis like BookStack or Wiki.js 3 are better for documentation that many people read and a few people write. For quick thoughts, Memos is much lighter. AFFiNE's niche is the combination: Notion-style pages, a Miro-style canvas and simple databases in one local-first app with native clients.
Conclusion
AFFiNE is one of the most polished open-source Notion alternatives you can run yourself. The new Compose template makes the first start pleasantly short: one directory, one config file, docker compose up -d. The trade-offs are real: it needs a few gigabytes of RAM, it's still pre-1.0, and you should understand the license split and the 10-seat limit. For a household or a small team that wants docs, boards and whiteboards without handing their notes to a SaaS, it's well worth an evening of tinkering.
Looking for more tools like this? Browse the Productivity and Wiki tags.