dimah-survey
API reference

Packages

Choose the protocol, server, React, and SQL layers your application needs.

The four packages version together but keep runtime boundaries separate. A typical React application installs server and react, then adds db for the bundled SQL store.

Published on npm, still before 1.0.0. A release may change the API.

PackageInstall when you needDoes not own
@dimah-survey/coreProtocol types, clients, schemas, errors, or a custom storeSurveyJS runtime
@dimah-survey/serverHandlers, guards, validation, adapters, and local memoryUI or SQL ORM
@dimah-survey/reactModel and Creator lifecycle bindingsSurveyJS renderers
@dimah-survey/dbFumaDB-backed SQL storage and schema referencesYour migrations
npm i @dimah-survey/server @dimah-survey/react survey-core survey-react-ui

Add @dimah-survey/db fumadb for the bundled SQL store. Install survey-creator-core and survey-creator-react only when your application renders Creator.

@dimah-survey/server

Start here for backend integration:

  • dimahSurvey() for fill and editor instances
  • guardRespondent() and guardAnonymous() for fill guards
  • memoryAdapter() for local development and tests
  • checkSurveyResult() and clearSurveyResult() for validation behavior
  • adapters for Next.js, Node, Express, Hono, Fastify, Elysia, and SvelteKit

The package re-exports common error and client utilities for server convenience. Browser bundles should import clients from react or core.

@dimah-survey/react

Use this in React client code:

  • useSurveyResponse() and bindSurveyModel() for fill sessions
  • useSurveyDraft() and bindSurveyCreator() for Creator autosave
  • isStaleUpdate() for write-state handling
  • createFillClient() and createEditorClient() from core

It requires React and survey-core as peers. Your application imports survey-react-ui and survey-creator-react, constructs their objects, and renders their components.

@dimah-survey/core

Use core for non-React clients, shared protocol code, or custom stores. It contains the fill/editor clients, route constants, Zod schemas, stable error codes, list and settings helpers, and SurveyStore types.

Most applications use createFillClient() or createEditorClient(). Reach for createSurveyFetch() only when you need the lower-level better-fetch surface.

@dimah-survey/db

db(client) adapts a FumaDB client to SurveyStore. DimahSurveyDB describes the versioned schema; Drizzle, SQL, and Prisma exports are readable reference files.

Copy or generate those schema references into your application, then migrate the application-owned file. Do not import a reference schema into a running application.

The database package is optional. Any store must preserve immutable response definitions, compare-and-swap inside writes, and one open draft per identified respondent.

Continue with Configuration for runtime options or HTTP protocol for the operation map.

On this page