@electric-sql/next
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@electric-sql/next", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Postgres everywhere - your data, in sync, wherever you need it.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,15 +1,42 @@ | ||
<p align="center"> | ||
<a href="https://next.electric-sql.com" target="_blank"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" | ||
srcset="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-next.svg" | ||
/> | ||
<source media="(prefers-color-scheme: light)" | ||
srcset="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg" | ||
/> | ||
<img alt="ElectricSQL logo" | ||
src="https://raw.githubusercontent.com/electric-sql/meta/main/identity/ElectricSQL-logo-black.svg" | ||
/> | ||
</picture> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://github.com/electric-sql/electric-next/actions"><img src="https://github.com/electric-sql/electric-next/workflows/CI/badge.svg" alt="CI"></a> | ||
<a href="https://github.com/electric-sql/electric-next/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache_2.0-green" alt="License - Apache 2.0"></a> | ||
<a href="https://github.com/electric-sql/electric-n | ||
ext/milestones"><img src="https://img.shields.io/badge/status-alpha-orange" alt="Status - Alpha"></a> | ||
<a href="https://discord.electric-sql.com"><img src="https://img.shields.io/discord/933657521581858818?color=5969EA&label=discord" alt="Chat - Discord"></a> | ||
<a href="https://x.com/ElectricSQL" target="_blank"><img src="https://img.shields.io/twitter/follow/ElectricSQL.svg?style=social&label=Follow @ElectricSQL"></a> | ||
</p> | ||
# TypeScript client for ElectricSQL | ||
Postgres sync for modern apps. | ||
Real-time Postgres sync for modern apps. | ||
Electric provides an HTTP interface to Postgres to enable massive number of clients to query and get real-time updates to data in "shapes" i.e. subsets of the database. Electric turns Postgres into a real-time database. | ||
Electric provides an [HTTP interface](https://next.electric-sql.com/api/http) to Postgres to enable a massive number of clients to query and get real-time updates to subsets of the database, called [Shapes](https://next.electric-sql.com//guides/shapes). In this way, Electric turns Postgres into a real-time database. | ||
The TypeScript client helps ease reading shapes over the API in the browser and in server JavaScript applications. | ||
The TypeScript client helps ease reading Shapes from the HTTP API in the browser and other JavaScript environments, such as edge functions and server-side Node/Bun/Deno applications. It supports both fine-grained and coarse-grained reactivity patterns — you can subscribe to see every row that changes, or you can just subscribe to get the whole shape whenever it changes. | ||
The TypeScript client supports both fine-grained and coarse-grained reactivity patterns. You can subscribe to see every row that changes or just to when the shape as a whole changes. | ||
## Install | ||
`npm i @electricsql/next` | ||
The client is published on NPM as [`@electric-sql/next`](https://www.npmjs.com/package/@electric-sql/next): | ||
```sh | ||
npm i @electric-sql/next | ||
``` | ||
## How to use | ||
@@ -22,22 +49,25 @@ | ||
```tsx | ||
import { ShapeStream } from "electric-sql" | ||
import { ShapeStream } from 'electric-sql' | ||
// passes subscribers rows as they're inserted, updated, or deleted | ||
const fooShapeStream = new ShapeStream({ | ||
shape: { table: `foo` }, | ||
baseUrl: `${BASE_URL}`, | ||
// Passes subscribers rows as they're inserted, updated, or deleted | ||
const stream = new ShapeStream({ | ||
baseUrl: `${BASE_URL}`, | ||
shape: { table: `foo` } | ||
}) | ||
fooShapeStream.subscribe(messages => { | ||
// messages is 1 or more row updates | ||
stream.subscribe(messages => { | ||
// messages is an array with one or more row updates | ||
}) | ||
``` | ||
## `Shape` | ||
### `Shape` | ||
```tsx | ||
import { ShapeStream, Shape } from "electric-sql" | ||
import { ShapeStream, Shape } from 'electric-sql' | ||
const shapeStream = new ShapeStream({ shape: { table: `foo` }, baseUrl: 'http://localhost:3000' }) | ||
const shape = new Shape(shapeStream) | ||
const stream = new ShapeStream({ | ||
baseUrl: `${BASE_URL}`, | ||
shape: { table: `foo` } | ||
}) | ||
const shape = new Shape(stream) | ||
@@ -52,1 +82,3 @@ // Returns promise that resolves with the latest shape data once it's fully loaded | ||
``` | ||
See the [Docs](https://next.electric-sql.com) and [Examples](https://next.electric-sql.com/examples/basic) for more information. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53209
83