# Quick Start
Source: https://docs.maelstrom-ai.co/dev/getting-started/quick-start/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

> [!NOTE]
> Public npm packages
> 
> The install commands use the latest stable release from npm. No GitHub token is required.

By the end of this guide you’ll have a chart with one vessel, driven by a running Maelstrom engine that interprets a natural-language intent and positions the component on screen. The visible result is deliberately small: a single greeting card appears where the engine places it, proving that the client, connector, engine, and chart can complete one full turn.

> [!TIP]
> Use with a coding agent
> 
> [Build with an agent](https://docs.maelstrom-ai.co/agents/skills/) provides installation, discovery checks, and a safe first task. The [project onboarding prompt](https://docs.maelstrom-ai.co/agents/prompts/maelstrom-project-onboarding/) defaults to planning with no edits; choose implementation authority explicitly when approving a bounded change. The [SDK scaffold prompt](https://docs.maelstrom-ai.co/agents/prompts/maelstrom-sdk-scaffold/) is for an authorized implementation. Both inspect the app and installed SDK first.
> 
> Integrate Maelstrom into a project
> 
> ```
> 
> Help me get started with Maelstrom. Ask what I want to build and whether I am
> starting a new application or integrating an existing one, unless that is already
> clear from the conversation. Inspect the project and plan a bounded integration
> for this goal:
> 
> [PRODUCT GOAL]
> 
> Repository root: [PATH]
> 
> Requested authority: [PLAN ONLY | IMPLEMENT THE BOUNDED INTEGRATION]
> 
> If authority is omitted or the placeholder is unchanged, use PLAN ONLY.
> For PLAN ONLY, make no edits or installations. Report the selected pilot and
> verification plan, then stop. For IMPLEMENT THE BOUNDED INTEGRATION, inspect first
> and implement the smallest useful pilot. Ask only when inspection reveals a
> material decision outside the authorized goal.
> 
> ## Inspect and select
> 
> For a new app, inspect the destination before creating anything. Start from the
> runnable React starter at https://github.com/maelstrom-co/react-starter#run
> when React fits the goal. Its deterministic local planner needs no provider key;
> do not describe that run as live model verification. For PLAN ONLY, describe the
> starter and checks without downloading, installing, or editing. For an authorized
> implementation, use an empty destination, follow its README, then adapt the
> smallest useful capability to the stated goal. Preserve existing files when the
> destination is not empty. If the installed maelstrom skill is available, use its
> entry workflow and selected procedure; this prompt also works without skills.
> 
> 1. Read package manifests and lockfile, application entry/root, routing, relevant UI,
>    state/data/network code, server boundary, and existing tests. Record installed
>    `@maelstrom-co/*` package versions; do not infer them from documentation or a
>    version tag.
> 2. Inventory the existing user-visible capabilities relevant to the goal. For
>    each candidate cite the source evidence and a plausible user intent, explain
>    whether the Engine can meaningfully select and present it as a unit, and decide
>    whether to expose it as a Vessel or keep it internal.
> 3. Select only the smallest useful pilot. Keep buttons, badges, loading indicators,
>    and other implementation details inside their capability unless they are
>    independently meaningful product capabilities. A useful single-Variant
>    Vessel with no Actions is valid. Do not invent states, operations, or product
>    behavior.
> 4. State any SDK version mismatch or unavailable dependency before choosing APIs.
>    Use APIs present in the installed version's source/types/docs, not illustrative
>    or remembered APIs.
> 
> ## Implement only when authorized
> 
> For IMPLEMENT THE BOUNDED INTEGRATION, define/register only the
> selected developer-owned Vessels, preserve existing UI and routing where
> practical, and add the smallest intent entry point needed for the goal. For React,
> prefer the installed `@maelstrom-co/react` APIs where the architecture allows.
> Keep the Connector focused on transport and application authentication in its
> existing owner. Never expose provider credentials in browser code, request or
> print literal credentials, or move provider decisions into the browser. The Engine
> selects among developer-authored Vessels; do not replace them with model-generated
> JSX. Keep layout state client-owned.
> 
> Do not expand into voice, a broad migration, unrelated refactors, or a new auth
> system. Do not invent an Engine response or claim an intent was verified against a
> real Engine when only a stub or static check was available. Use an existing
> supported test connector only when it actually tests the assertion; otherwise
> record that live Engine verification needs separately configured infrastructure.
> 
> ## Verify and report
> 
> For an implemented change, run the relevant project typecheck, tests, and lint/format checks. Verify the
> bounded UI integration and intent path using the available documented test setup;
> report live Engine verification separately. Inspect the final diff for accidental
> secrets and unrelated changes. For PLAN ONLY, distinguish proposed checks from
> checks actually run and state that no files changed.
> 
> Return:
> - observed architecture and installed package versions;
> - candidate inventory with evidence, user intent, Engine value, and expose/internal
>   decision;
> - selected pilot and its observed state/action contract;
> - changed files and exact verification commands/results;
> - credential and browser/server-boundary review;
> - remaining infrastructure needs, limitations, and rollback path.
> ```
> Scaffold an SDK integration
> 
> ```
> 
> Integrate the Maelstrom SDK into this application for the following bounded goal:
> 
> [PRODUCT GOAL]
> 
> Repository: [PATH]
> App/package: [PATH OR "discover"]
> Installed Maelstrom versions: [KNOWN OR "inspect manifests and lockfile"]
> 
> ## Inspect before implementation
> 
> 1. Read the app entrypoints, dependency manifests and lockfile, current UI/data
>    flow, server/browser boundaries, and tests. Record exact installed versions;
>    do not infer versions from a tag, docs example, or this prompt's compatibility
>    metadata.
> 2. Trace the public API from the installed package's exports, declaration files,
>    source and version-matched docs. Follow existing consumers and tests where
>    useful. If the proposed symbol is absent or its contract is unclear, stop that
>    part and report the evidence rather than substituting a remembered API.
> 3. Keep `@maelstrom-co/client` framework-independent. Put React rendering and
>    React bindings in `@maelstrom-co/react`; do not import React into client code.
>    Use developer-authored Vessels as capabilities, not generated runtime JSX.
> 4. Identify whether the request authorizes implementation. If so, make the
>    smallest bounded change after inspection; do not add an approval round unless
>    inspection reveals an unresolved material decision.
> 
> ## Implement and verify
> 
> Preserve existing product behavior and app-owned state, authentication, and
> network effects. The Connector carries transport; it is not an Action handler or
> product policy layer. Keep provider secrets on the server. Do not claim a live
> Engine check when only types, tests, stubs, or local rendering were exercised.
> 
> Run the affected project's typecheck, tests, and check/lint commands. Add focused
> deterministic tests for the integration boundary. Report actual commands and
> results separately from recommended checks not run.
> 
> Return exact package versions and source/export anchors, changed files, the
> bounded API usage and ownership boundaries, tests/commands/results, unverified
> behavior, and remaining integration work. Do not produce a general SDK tutorial
> or rewrite unrelated framework-neutral SDK code.
> ```

Starting a new app? Use the [runnable React starter](https://docs.maelstrom-ai.co/dev/getting-started/starter/) for a complete local example with no provider key. This guide starts from an existing React app and a running Engine.

> [!NOTE]
> Prerequisites
> 
> -   Node 20+ or Bun
> -   A running Maelstrom engine — clone the [demo repo](https://github.com/maelstrom-co/maelstrom) and run `nx dev demo` to start the reference WebSocket engine
> -   An LLM provider API key (OpenAI) — see [Installation](https://docs.maelstrom-ai.co/dev/getting-started/installation/) for details

1.  ## Install packages
    
    **npm**
    
    Terminal window
    
    ```bash
    npm install @maelstrom-co/react
    ```
    
    **bun**
    
    Terminal window
    
    ```bash
    bun add @maelstrom-co/react
    ```
    
    **pnpm**
    
    Terminal window
    
    ```bash
    pnpm add @maelstrom-co/react
    ```
    
    `@maelstrom-co/react` re-exports the vessel definition helper and connector classes (`WebSocketConnector`, `HttpConnector`), so you do not need to install lower-level Maelstrom packages separately for React apps.
    
2.  ## Create a component
    
    First, create the React component that will render inside the vessel:
    
    src/components/Greeting.tsx
    
    ```tsx
    export function Greeting({ message }: { message: string }) {
      return (
        <div className="rounded-lg border p-4">
          {message}
        </div>
      );
    }
    ```
    
    This is just a regular React component. Maelstrom doesn’t impose any prop conventions — you define what the component receives via the vessel’s variant `props`.
    
3.  ## Define a Vessel
    
    A vessel is a state machine: variants are its states, actions are transitions between them, and the LLM uses the `description` fields to understand what the vessel does and how to position it.
    
    `minSize` is in chart cells. The engine enforces it for grid layouts. Tiling layouts derive each Vessel’s size from the split tree and ignore `minSize`.
    
    src/vessels/greeting.tsx
    
    ```tsx
    import { defineVessel, vessel } from '@maelstrom-co/react';
    import { Greeting } from '../components/Greeting';
    
    export const greetingVessel = vessel(
      defineVessel({
        id: 'greeting',
        name: 'Greeting',
        description: 'Displays a greeting message to the user.',
        defaultVariant: 'compact',
        variants: {
          compact: {
            description: 'Short one-line greeting',
            props: { message: 'Hello!' },
            minSize: { width: 2, height: 1 },
            actions: [],
          },
        },
      }),
      ({ variantProps }) => <Greeting message={variantProps.message} />,
    );
    ```
    
    `defineVessel(...)` declares the framework-agnostic state machine. `vessel(...)` supplies the active Variant through `variantProps`; the adapter passes its `message` to the existing React component.
    
4.  ## Wire the Provider
    
    Create a shared module that exports the Maelstrom instance, then wrap your app with `m.Provider`:
    
    src/maelstrom.ts
    
    ```ts
    import { createMaelstrom } from '@maelstrom-co/react';
    import { greetingVessel } from './vessels/greeting';
    
    export const m = createMaelstrom({
      vessels: [greetingVessel],
    });
    ```
    
    src/App.tsx
    
    ```tsx
    import { WebSocketConnector } from '@maelstrom-co/react';
    import { m } from './maelstrom';
    
    const connector = new WebSocketConnector({
      url: 'ws://localhost:3001/ws',
    });
    
    export function App() {
      return (
        <m.Provider connector={connector}>
          <m.Chart style={{ height: '100vh' }} />
        </m.Provider>
      );
    }
    ```
    
    `m.Chart` renders the grid canvas. The engine emits layout directives that the client applies as CSS positioning — you don’t manage positions manually.
    
5.  ## Submit an intent
    
    Add a simple input that calls `processIntent`. The `useMaelstrom` hook exposes connection state so you can give the user feedback while the engine is thinking:
    
    src/IntentBar.tsx
    
    ```tsx
    import { useState } from 'react';
    import { m } from './maelstrom';
    
    export function IntentBar() {
      const { processIntent, connectionStatus, isProcessing } = m.useMaelstrom();
      const [value, setValue] = useState('');
    
      return (
        <form
          onSubmit={(e) => {
            e.preventDefault();
            if (!value.trim()) return;
            void processIntent(value.trim());
            setValue('');
          }}
        >
          <input
            value={value}
            onChange={(e) => setValue(e.target.value)}
            placeholder="Tell the engine what to show…"
            disabled={connectionStatus !== 'connected' || isProcessing}
          />
          <button type="submit" disabled={connectionStatus !== 'connected' || isProcessing}>
            {isProcessing ? 'Thinking…' : 'Send'}
          </button>
        </form>
      );
    }
    ```
    
    Add `<IntentBar />` below `<m.Chart />` in your `App.tsx`.
    
6.  ## What you should see
    
    Type something like `show me a greeting` and submit. The engine processes the intent and the greeting vessel appears on the chart at the grid position the engine chose. You should see one small card containing `"Hello!"` inside the chart area; the exact position may vary because the engine chooses the layout.
    
    The engine response includes layout directives — the client applies CSS positioning to place the vessel without you writing any placement code.
    
    If the vessel doesn’t appear, check:
    
    -   The WebSocket engine is running (clone the [demo repo](https://github.com/maelstrom-co/maelstrom) and run `nx dev demo`)
    -   Your `.env` has a valid `OPENAI_API_KEY`
    -   The browser console for WebSocket connection errors

## Next steps

-   [Debug applications with DevTools](https://docs.maelstrom-ai.co/dev/guides/devtools/) — inspect requests, layouts, and Action outcomes, then record a problem
-   [Core Concepts](https://docs.maelstrom-ai.co/dev/getting-started/core-concepts/) — vessels, charts, the engine, and the protocol in depth
-   [Installation](https://docs.maelstrom-ai.co/dev/getting-started/installation/) — full setup matrix for all LLM providers and package managers
-   [Build Your First Dashboard](https://docs.maelstrom-ai.co/dev/tutorials/first-dashboard/) — multi-vessel app with real actions
-   [React guides](https://docs.maelstrom-ai.co/dev/guides/react/creating-vessels/) — variants, actions, lazy loading, error handling
-   [Client guides](https://docs.maelstrom-ai.co/dev/guides/client/custom-connectors/) — custom connectors, programmatic layout
-   [API Reference](https://docs.maelstrom-ai.co/dev/reference/react/readme/) — full TypeDoc for all packages
