stable

nuxt

Nuxt 4 module — one `noydb` config block auto-imports the in-vue/in-pinia composables and wires an SSR-safe client-only runtime plugin.

@noy-db/in-nuxt · pnpm add @noy-db/in-nuxt @noy-db/hub @noy-db/in-pinia @noy-db/in-vue Nuxt 4 module — auto-imports, SSR-safe runtime plugin, and the in-pinia bridge. Nuxt 4+ only — Nuxt 3 apps should wire in-vue / in-pinia by hand.

What it does

Add '@noy-db/in-nuxt' to modules, configure a noydb block, and every component gets useNoydb, useCollection, useSync (from in-vue) plus defineNoydbStore, setActiveNoydb, getActiveNoydb (from in-pinia) auto-imported. The module does not auto-instantiate the Noydb instance — its runtime plugin registers with mode: 'client' only, so the server bundle never imports crypto code; you construct the instance yourself (typically in plugins/noydb.client.ts) and call setActiveNoydb(db). During SSR, useCollection returns empty reactive state and stores hydrate to their initial state — no keys or decryption ever reach the server.

Usage

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@noy-db/in-nuxt'],
  noydb: { store: 'to-browser-idb', pinia: true },
})
The key is store, naming a package — not adapter: 'browser'.ModuleOptions.store accepts 'to-browser-idb' | 'to-browser-local' | 'to-memory' | 'to-file' | 'to-aws-dynamo' | 'to-aws-s3' and defaults to 'to-browser-idb'; inside sync the field is sync.store, same package names. Older material — including this module's own README before 0.7.0-pre.13 — showed adapter: in both places; neither the key nor the value vocabulary is right. The option is only a hint to the runtime plugin either way — you can always construct a store and pass it to createNoydb() yourself, which is what this module expects you to do.

The full option set is store, pinia, sync ({ store, table, region, bucket, mode }), auth ({ mode, sessionTimeout }), devtools, and rest ({ enabled, basePath, authToken }).

// stores/invoices.ts — defineNoydbStore is auto-imported
export const useInvoices = defineNoydbStore<Invoice>('invoices', { compartment: 'C101' })

See also