Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@electric-sql/next

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electric-sql/next

The Next Electric

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
0
Weekly downloads
 
Created
Source

TypeScript client for ElectricSQL

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.

The TypeScript client helps ease reading shapes over the API in the browser and in server JavaScript applications.

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

How to use

The client exports a ShapeStream class for getting updates to shapes on a row-by-row basis as well as a Shape class for getting updates to the entire shape.

ShapeStream

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}`,
})

fooShapeStream.subscribe(messages => {
  // messages is 1 or more row updates
})

Shape

import { ShapeStream, Shape } from "electric-sql"

const shapeStream = new ShapeStream({ shape: { table: `foo` }, baseUrl: 'http://localhost:3000' })
const shape = new Shape(shapeStream)

// Returns promise that resolves with the latest shape data once it's fully loaded
await shape.value

// passes subscribers shape data when the shape updates
shape.subscribe(shapeData => {
  // shapeData is a Map of the latest value of each row in a shape.
}

FAQs

Package last updated on 17 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc