# Packages (https://survey.dimah.dev/docs/packages)



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.

<Callout>
  Published on npm, still before `1.0.0`. A release may change the API.
</Callout>

| Package                | Install when you need                                       | Does not own       |
| ---------------------- | ----------------------------------------------------------- | ------------------ |
| `@dimah-survey/core`   | Protocol types, clients, schemas, errors, or a custom store | SurveyJS runtime   |
| `@dimah-survey/server` | Handlers, guards, validation, adapters, and local memory    | UI or SQL ORM      |
| `@dimah-survey/react`  | `Model` and Creator lifecycle bindings                      | SurveyJS renderers |
| `@dimah-survey/db`     | FumaDB-backed SQL storage and schema references             | Your migrations    |

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npm i @dimah-survey/server @dimah-survey/react survey-core survey-react-ui
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm add @dimah-survey/server @dimah-survey/react survey-core survey-react-ui
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn add @dimah-survey/server @dimah-survey/react survey-core survey-react-ui
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun add @dimah-survey/server @dimah-survey/react survey-core survey-react-ui
    ```
  </CodeBlockTab>
</CodeBlockTabs>

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` [#dimah-surveyserver]

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` [#dimah-surveyreact]

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` [#dimah-surveycore]

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` [#dimah-surveydb]

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

<Callout type="warn">
  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.
</Callout>

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](https://survey.dimah.dev/docs/configuration.md) for runtime options or
[HTTP protocol](https://survey.dimah.dev/docs/protocol.md) for the operation map.
