Instant

Introduction

Getting started with Vanilla JS

You can use Instant with plain ol' Javascript too. You may find this helpful to integrate Instant with a framework that doesn't have an official SDK yet.

To use Instant in a non-react project you can install it like so

npm i @instantdb/core

Now you can import the main functions:

import { init, tx } from '@instantdb/core'

init

init works the same as in @instantdb/react:

const APP_ID = 'REPLACE ME'

const db = init({ appId: APP_ID })

Writing Data

db.transact works the same too:

db.transact([tx.goals[id()].update({ title: 'eat' })])

To learn more writing transactions, check out the Writing Data section.

Reading Data

Now that you have your database up and running, you can subscribe to queries:

const query = { goals: {} }
// subscribe a query
const unsub = db.subscribeQuery(query, (resp) => {
  if (resp.error) {
    console.error('Uh oh!', resp.error.message)
  }
  if (resp.data) {
    console.log('Data!', resp.data)
  }
})

Continue on to the Explore section to learn more about how to use Instant :)