This repo is now archived and work has moved back to https://github.com/electric-sql/electric
Your Postgres data, in sync, wherever you need it.
This is a clean rebuild of the ElectricSQL sync engine. One that's informed by the lessons learned building the previous system. See James' blog post for background on the change: https://next.electric-sql.com/about
It provides an HTTP API for syncing Shapes of data from Postgres. This can be used directly or via client libraries and connectors.
It's also simple to write your own client in any language.
See the Quickstart guide to get up and running. In short, you need to:
- have a Postgres database with logical replication enabled; and then to
- run Electric in front of it, connected via
DATABASE_URL
For example, using Docker Compose from the root of this repo:
docker compose -f .support/docker-compose.yml up
You can then use the HTTP API to sync data from your Postgres. For example, to start syncing the whole foo
table:
curl -i 'http://localhost:3000/v1/shape/foo?offset=-1'
Or use one of the clients or connectors, such as the useShape
React hook:
import { useShape } from '@electric-sql/react'
function Component() {
const { data } = useShape({
url: `http://localhost:3000/v1/shape/foo`,
where: `title LIKE 'foo%'`,
})
return JSON.stringify(data)
}
Again, see the Quickstart and the Docs for more details.
The HTTP API is defined in an OpenAPI spec in docs/electric-api.yaml.
We're using asdf to install Elixir, Erlang, and Node.js. Versions are defined in .tool-versions.
brew install asdf
asdf plugin-add nodejs elixir erlang
asdf install
You'll probably need to fiddle with your bash/zsh/etc rc file to load the right tool into your environment.
See the:
We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.
It's also super helpful if you leave the project a star here at the top of the page☝️