pygy / examples

Example applications using ElectricSQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ElectricSQL logo

ElectricSQL Examples

This repo contains example applications illustrating how to use ElectricSQL with various drivers and frameworks.

See the sub folders for the actual applications:

Running the examples

Each example has usage instructions in the README. It may also be helpful to read through the ElectricSQL usage documentation, including the sections on configuration, migrations and the relevant section of the drivers guide.

Connecting to the backend

As a local-first system, ElectricSQL defaults to working without a backend. So you can run these applications without connecting to a replication service. However, to develop, test and run with replication working, you'll need to configure a backend to connect to.

Using the ElectricSQL service

The simplest way to configure a backend is to sign up to ElectricSQL and create an application. This will give you a globally unique app slug and an environment name. Paste this into your application config, which in these examples is typically defined in an electric-config.js file in the root of the example folder, e.g.:

const config = {
  app: '<YOUR APP SLUG>',
  env: '<YOUR ENV NAME>',
  // ... other configuration options ...
};

Running the backend locally

Alternatively, you can clone the electric-sql/electric repo and run locally using Makefile, Docker and Elixir 1.14 compiled with Erlang 24.

See the electric repo README for instructions but in short:

git clone https://github.com/electric-sql/electric
cd electric
make start_dev_env
make deps compile

Make sure you've built your migrations in your application folder, then set the MIGRATIONS_DIR environment variable to the path to the migrations folder:

export MIGRATIONS_DIR='../path/to/migrations'

Now run the electric service:

make shell

Apply the migrations locally:

make apply_migration name=$MIGRATION_NAME

Where MIGRATION_NAME is the name of a migration folder created using electric migrations new, for example:

make apply_migration name=1666288253_create_items

You can then configure your application to connect to the local backend using the replication config options:

const config = {
  replication: {
    address: 'localhost',
    port: 5133
  },
  // ... other configuration options ...
};

More information

See the documentation and community guidelines. If you need help let us know on Discord.

About

Example applications using ElectricSQL.

License:Apache License 2.0


Languages

Language:TypeScript 32.3%Language:Java 17.3%Language:JavaScript 15.0%Language:CSS 13.1%Language:C++ 8.0%Language:Objective-C++ 4.9%Language:HTML 3.4%Language:Objective-C 2.6%Language:Ruby 1.8%Language:Starlark 0.7%Language:Shell 0.5%Language:CMake 0.3%Language:Standard ML 0.0%