wervt
Dashboard
API

proxyShape

Serve an Electric shape from a route.
server/api/shapes/open-todos.get.ts
import { proxyShape } from '@wervt/nuxt/server'
import { defineEventHandler } from 'nuxt/server'
import { todos } from '../../db/schema'

export default defineEventHandler((event) =>
  proxyShape(event, { table: todos, where: 'done = $1', params: [false] }),
)
OptionType
tablePgTable | stringThe Drizzle table, or its name without schema.
wherestringSQL filter with $1, $2, … placeholders.
params(string | number | boolean)[]Values for the placeholders.
columnsstring[]Only sync these columns (the table's keys). Must include the primary key.

With the Drizzle table, the response carries the row type (typeof todos.$inferSelect), and useShape picks it up for every route in server/api/shapes/. With a table name, rows are untyped.

Forwards Electric's protocol parameters (offset, handle, live, cursor, …) from the client and returns Electric's response as a streaming Response. Of Electric's subset parameters it forwards only subset__where=true, the request for the shape's current rows, so a client can't filter or sort a shape by columns the route doesn't serve.

In production the request goes through the runtime's Electric gateway with the app's token. In nuxt dev it goes to Electric directly with the schema-qualified table.

Do your auth checks before calling proxyShape. Anyone who can call the route can read the shape.
Copyright © 2026