Skip to content
On this page

Plugins

Here you will find more information on each official store plugin for Magnetar.

Please note that the documentation below is still WIP

Firestore

Use the Firestore plugin if you use Cloud Firestore. This plugin wraps the firebase JS SDK for use in the browser.

documentation WIP

Example setup:

js
import { PluginFirestore } from 'magnetar'
import { initializeApp } from 'firebase/app'
import { getFirestore } from 'firebase/firestore'

const firebaseApp = initializeApp({ /* pass your config... */ })
const db = getFirestore(firebaseApp)

const remote = PluginFirestore.CreatePlugin({ db })

You can enable console logging by adding debug: true when you set up the plugin:

ts
const remote = PluginFirestore.CreatePlugin({ db, debug: true })

Firebase Admin (for Firestore)

Use the Firestore Admin plugin if you use Cloud Firestore and you want to use Magnetar in NodeJS (eg. Cloud Functions). This plugin wraps the firebase-admin NodeJS SDK.

documentation WIP

Example setup:

js
import { CreatePlugin as PluginFirestoreAdmin } from '@magnetarjs/plugin-firestore-admin'
import { initializeApp } from 'firebase-admin/app'
import { getFirestore } from 'firebase-admin/firestore'

const firebaseApp = initializeApp({ /* pass your config... */ })
const db = getFirestore(firebaseApp)

const remote = PluginFirestoreAdmin({ db })

You can enable console logging by adding debug: true when you set up the plugin:

ts
const remote = PluginFirestore.CreatePlugin({ db, debug: true })

Vue 3

documentation WIP

Use the Vue 3 plugin for Vue 3 projects.

Example setup:

js
import { PluginVue3 } from 'magnetar'

function generateRandomId() {
  return [Math.random(), Math.random(), Math.random()].join('-')
  // you need to provide your own logic
  // this function is used when you execute `insert` without specifying an ID
}

const local = PluginVue3.CreatePlugin({ generateRandomId })

Vue 2

documentation WIP

Use the Vue 2 plugin for Vue 2 projects.

Example setup:

js
import { CreatePlugin as CreatePluginVue2 } from '@magnetarjs/plugin-vue2'
import vue from 'vue'

function generateRandomId() {
  return [Math.random(), Math.random(), Math.random()].join('-')
  // you need to provide your own logic
  // this function is used when you execute `insert` without specifying an ID
}

const local = CreatePluginVue2({ vueInstance: vue, generateRandomId })

Simple Store

documentation WIP

The Simple Store has no built-in reactivity. Good for a lightweight solution in React / Svelte projects.

Example setup:

js
import { PluginSimpleStore } from 'magnetar'

function generateRandomId() {
  return [Math.random(), Math.random(), Math.random()].join('-')
  // you need to provide your own logic
  // this function is used when you execute `insert` without specifying an ID
}

const local = PluginSimpleStore.CreatePlugin({ generateRandomId })

Made with 💛 by Mesqueeb