Giter Site home page Giter Site logo

louwers / crsqlite-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vlcn-io/js

0.0 0.0 0.0 803 KB

Components to build apps in JavaScript atop cr-sqlite

License: MIT License

Shell 0.86% JavaScript 1.55% TypeScript 96.31% CSS 0.80% Makefile 0.19% HTML 0.28%

crsqlite-js's Introduction

crsqlite-js

JavaScript packages to use cr-sqlite in the browser, node, react and other JS frameworks & environments.

Quickstart

Scaffolding a new project -- https://github.com/vlcn-io/vite-starter/tree/main

Example apps:

Video overview

Browser

import initWasm from "@vlcn.io/crsqlite-wasm";
import wasmUrl from "@vlcn.io/crsqlite-wasm/crsqlite.wasm?url";

const crsqlite = await initWasm(wasmUrl);
const db = await sqlite.open("db-name");

...

db.close();

NodeJS

import Database from "better-sqlite3";

const db = new Database(":memory:");
import { extensionPath } from "@vlcn.io/crsqlite";
db.loadExtension(extensionPath);

...

db.close();

React

function TodoList() {
  const allTodos: readonly Todo[] = useQuery<Todo>(
    ctx,
    "SELECT * FROM todo ORDER BY id DESC"
  ).data;

  return (
    <div>
      {allTodos.map((t) => (
        <Todo item={t} />
      ))}
    </div>
  );
}

Sync

See official docs or the vite-starter

Packages

Storage

  • crsqlite: The cr-sqlite loadable extension for use in NodeJS/Deno/Bun. Can be used with the SQLite bindings you currently use.
  • crsqlite-wasm: WASM build of CR-SQLite & SQLite for use in the browser.

Sync

UI

  • react: React hooks for driving UI state from database queries

Other

  • xplat-api: interfaces for components that can exist in NodeJS or the Browser.
  • client-core: Networking code that is common across all client implementations
  • client-server-common: Networking code that is common to the client and server
  • server-core: Network code that is common across all server implementations
  • node-allinone: convenience package for loading and using crsqlite in nodejs
    • Can also be used as a run time loadable extension in nodejs with whatever sqlite bindings you already use. See the node-allinone readme for more details
  • tsbuild-all: convenient package for building all other packages

Integration Tests

  • node-tests:
  • xplat-tests:
  • browser-tests:

Contributing

If you want to build these projects from source and/or hack on them or contribute, you'll need to clone the workspace repository:

git clone --recurse-submodules [email protected]:vlcn-io/workspace.git

Running make in that directory will get you set up. Ensure you have the rust nightly toolchain installed and activated before running make.

crsqlite-js's People

Contributors

tantaman avatar alexerrant avatar jmatsushita avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.