Each example is structured like a repository root. The powersync/ folder contains all PowerSync service configuration:
local-postgres/
├── powersync/ # PowerSync service config
│ ├── docker/ # Docker Compose for PowerSync
│ │ ├── docker-compose.yaml
│ │ └── modules/ # Database and storage modules
│ │ ├── database-postgres/
│ │ │ ├── init-scripts/ # Schema and publication
│ │ │ └── postgres.database.compose.yaml
│ │ └── storage-postgres/
│ │ ├── init-scripts/
│ │ └── postgres.storage.compose.yaml
│ ├── cli.yaml # Instance link (api_url, api_key)
│ ├── service.yaml # Service config (connections, auth)
│ └── sync-config.yaml # Sync config
└── README.md
powersync init self-hostedpowersync docker configure --database=postgres --storage=postgresCreate files in powersync/docker/modules/database-postgres/init-scripts/:
00-schema.sql– your schema (e.g.todostable)01-powersync-publication.sql–CREATE PUBLICATION powersync FOR ALL TABLES;
Note: Init scripts run only when the Postgres data directory is empty. If you see "Publication 'powersync' does not exist", remove the database volume and redeploy:
powersync docker stop --remove --remove-volumesthenpowersync docker reset.
Ensure powersync/sync-config.yaml includes rules for your tables (e.g. SELECT * FROM todos in a bucket).
powersync docker startThis project can be used with any self-hosted CLI commands:
powersync status
powersync generate schema --output-path=schema.ts --output=ts