stable

nextjs

Next.js App Router helpers — dual-entry: cookie-session server helpers at the root, and a `/client` re-export of in-react's hooks.

@noy-db/in-nextjs · pnpm add @noy-db/hub @noy-db/in-nextjs Next.js App Router helpers for noy-db — thin bridge over @noy-db/in-react and Next's cookies() / headers().

What it does

Two entry points. The default export is server-only: cookieSession() reads/writes an opaque session token (not the vault secret) via Next's cookies(), configureNoydb({ factory, session? }) wires a Noydb factory once, and withVault(name, handler) / withNoydb(handler) wrap route handlers with a resolved vault or instance. @noy-db/in-nextjs/client simply re-exports @noy-db/in-react's hooks (useNoydb, useVault, useCollection, …) so 'use client' files never pull in next/headers. next/headers itself is imported dynamically, so the server helpers stay test-runnable outside a Next runtime.

Usage

// app/api/invoices/route.ts
import { withVault } from '@noy-db/in-nextjs'
import { NextResponse } from 'next/server'

export const GET = withVault('acme', async (vault) => {
  const invoices = await vault.collection('invoices').list()
  return NextResponse.json(invoices)
})
// 'use client' component
import { useCollection } from '@noy-db/in-nextjs/client'

See also