@usevane/next
v0.1.7
Published
Next.js adapter for Vane. Proxy middleware, custom signal API, and instrumentation hook.
Readme
@usevane/next
Next.js adapter for Vane. Proxy middleware, custom signal API, and instrumentation hook.
bun add @usevane/nextRequires next >= 15.0.0 as a peer dependency.
Setup
1. Environment
VANE_API_KEY=proj_xxx2. Middleware proxy
Create or update your middleware to capture traffic signals on every request. The proxy never blocks responses -- it ships signals via waitUntil and fails open on any error.
// middleware.ts
import { createProxy } from '@usevane/next'
export default createProxy()
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}3. Instrumentation (optional)
Warm the config cache on server startup so the first request skips the fetch.
// instrumentation.ts
export { register } from '@usevane/next/instrumentation'Custom signals
Send domain-specific events that bypass sampling. Resolves when queued (<1ms) -- does not wait for Redis confirmation.
import { vane } from '@usevane/next'
await vane.signal('clickthrough', { entity: '/pricing' })
await vane.signal('checkout', { entity: '/cart', amount: 99 })Exports
| Entrypoint | Export | Description |
|:-----------|:-------|:------------|
| @usevane/next | createProxy | Middleware factory -- captures traffic signals |
| @usevane/next | vane | Custom signal API (vane.signal()) |
| @usevane/next | createVercelAdapter | Low-level Vercel platform adapter |
| @usevane/next/instrumentation | register | Next.js instrumentation hook |
Constraints
- Edge-runtime compatible. No Node.js APIs.
nextis a peer dependency -- never bundled.- Always fails open. Signal capture errors never break your app.
Docs
License
MIT
