dimah-surveyv0.5.0
API reference

Packages

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

The four packages version together but keep runtime boundaries separate. Most React applications use server, db, and react.

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

PackageResponsibility
@dimah-survey/coreProtocol types, browser clients, schemas, and store contracts
@dimah-survey/serverHandlers, guards, validation, and runtime adapters
@dimah-survey/reactSurveyJS Model and Creator bindings
@dimah-survey/dbFumaDB-backed SQL store and schema references
npm i @dimah-survey/server @dimah-survey/db @dimah-survey/react survey-core survey-react-ui

Database installs fumadb and adds the tables to Drizzle, Prisma, or Kysely. Install survey-creator-core and survey-creator-react when you render Creator.

@dimah-survey/server

Backend integration:

  • dimahSurvey() for fill and editor instances
  • memoryAdapter() for a process-local store
  • guardRespondent() and guardAnonymous() for fill guards
  • checkSurveyResult() for submit validation
  • clearSurveyResult() for partial-save sanitization
  • adapters for Next.js, Node, Express, Hono, Fastify, Elysia, and SvelteKit

Browser bundles should import clients from react or core, not server.

@dimah-survey/react

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 clients, route constants, Zod schemas, stable error codes, 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.

memoryAdapter() keeps rows in the process for tests. @dimah-survey/db is the SQL store. Implement SurveyStore when those tables cannot live in your database. See Database.

Continue with Configuration or the HTTP protocol.

On this page