nextjs
@noy-db/in-nextjs·pnpm add @noy-db/hub @noy-db/in-nextjsNext.js App Router helpers for noy-db — thin bridge over@noy-db/in-reactand Next'scookies()/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
- in-* family
- react — the hooks re-exported under
/client