Getting Started
Welcome to the Getting Started Guide for SignalDB, a local-first database with signal-based reactivity and real-time synchronization. This guide will help you understand the basics of SignalDB and get you up and running quickly.
SignalDB is designed for blazing fast query performance and data persistence, while remaining framework-agnostic.
Installation
Installing SignalDB is simple and easy. It can be installed using npm. Open your terminal and enter the following command:
$ npm install @signaldb/coreCreating Collections
Creating collections is straight forward.
import { Collection } from '@signaldb/core'
const posts = new Collection()but normally you want to persist your data. Persistence in SignalDB is achieved by giving the collection a data adapter that is backed by a storage adapter. Choose one that fits your needs. Here is an example using @signaldb/localstorage:
import { Collection, DefaultDataAdapter } from '@signaldb/core'
import createLocalStorageAdapter from '@signaldb/localstorage'
const dataAdapter = new DefaultDataAdapter({
storage: name => createLocalStorageAdapter(name),
})
const posts = new Collection('posts', dataAdapter)One data adapter serves every collection of your application — it is asked for the storage belonging to each collection by name, so you build it once and pass it to all of them.
That's all you have to do. There a also some optional configuration options you find here: collections reference
Adding data
After you've created you first collection, you can start to add documents to it.
// ...
const postId = await posts.insert({ title: 'Foo', text: 'Lorem ipsum …' })Writes are asynchronous — the promise resolves once the data layer has confirmed the write, while your queries already show it. You created your first document in SignalDB! Check out the data manipulation page to learn how to update and remove documents.
Querying
Getting your documents back is also very easy.
// ...
const cursor = posts.find({})
console.log(cursor.fetch()) // returns an array with all documents in the collectionYou've finished the Getting Started Guide! The next steps are getting reactivity to work. Check out the core concepts about reactivity to learn how to do this.
Next steps
Now you know the basics about SignalDB. It's time to learn how to integrate it with the framework you're using. Take a look at our guides:
After that you might want to learn more about the core concepts of SignalDB, how you can query your data or how to connect it to your backend.