If you are not using Igniter, you can configure Phoenix.Sync manually. The configuration depends on whether you are using :embedded or :http mode.
Embedded Mode
In :embedded mode, Electric is an application dependency and Phoenix.Sync consumes data internally via Elixir APIs. This is the most efficient mode for local development.
HTTP Mode
In :http mode, Phoenix.Sync consumes data from an external Electric service via its HTTP API. This is useful for production environments using Electric Cloud or when running Electric as a separate service.
# Example for Embedded Mode
# mix.exs
defp deps do
[
{:electric, "~> 1.0"},
{:phoenix_sync, "~> 0.6"}
]
end
# config/config.exs
config :phoenix_sync,
env: config_env(),
mode: :embedded,
repo: MyApp.Repo
# application.ex
children = [
MyApp.Repo,
# ...
{MyApp.Endpoint, phoenix_sync: Phoenix.Sync.plug_opts()}
]
# Example for HTTP Mode
# mix.exs
defp deps do
[
{:phoenix_sync, "~> 0.6"}
]
end
# config/config.exs
config :phoenix_sync,
env: config_env(),
mode: :http,
url: "https://api.electric-sql.cloud",
credentials: [
secret: "...", # required
source_id: "..." # optional, required for Electric Cloud
]
# application.ex
children = [
MyApp.Repo,
# ...
{MyApp.Endpoint, phoenix_sync: Phoenix.Sync.plug_opts()}
]