# @picked/client

The runtime of the Picked SDK: it loads your project's experiences, decides which ones a
visitor sees, and renders them through a framework plugin.

## Install

```bash
npm install picked
```

[`picked`](https://www.npmjs.com/package/picked) re-exports this package and adds the
`picked.config` helpers and the CLI. Install `@picked/client` on its own only when you want
neither.

## Usage

```typescript
import { createClient } from '@picked/client'
import { dynamicExperiencesPlugin } from '@picked/client/plugins/dynamic-experiences'
import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'

export const picked = createClient({
  projectId: 'your-project-id',
  plugins: [svelteFrameworkPlugin({ components: {} }), dynamicExperiencesPlugin()],
})

picked.start()
```

`start()` is idempotent. The main `createClient` options:

| Option         | Description                                                                                       |
| -------------- | ------------------------------------------------------------------------------------------------- |
| `projectId`    | The Picked project to load.                                                                       |
| `plugins`      | Plugins: a framework plugin, plus Dynamic Experiences or Create Experience.                       |
| `components`   | Components that render experiences, adapted with `adaptReactComponent` or `adaptSvelteComponent`. |
| `predicates`   | Functions of the client state, such as `location`, that decide when an experience renders.        |
| `features`     | Feature flags decided in code, each `{ key, name, decide }`.                                      |
| `previewToken` | Loads the unpublished draft of a workspace.                                                       |
| `apiUrl`       | The Picked API origin. Defaults to production.                                                    |

Plugins in this package:

- `@picked/client/plugins/dynamic-experiences` — loads the experiences your dashboard defines.
- `@picked/client/plugins/create-experience` — registers an experience you define in code.
- `@picked/client/plugins/single-page-app` — starts the client again on a history navigation.
- `@picked/client/plugins/window-object` — puts the client on `window.Picked` for debugging.

## Docs

- **Web:** [Picked SDK](https://docs.picked.app/reference/sdk)
- **Local:** `node_modules/picked/docs/reference/sdk/index.md`. The `picked` package carries every page under `node_modules/picked/docs/`.
- **CLI:** `npx picked docs read /reference/sdk`. `npx picked docs list [words]` lists the pages.
- **MCP:** call `read_picked_doc` with `{ "path": "/reference/sdk" }`; `list_picked_docs` lists the pages. Add the server with `claude mcp add --transport http picked https://api.picked.app/mcp`, or see [How to connect the MCP server](https://docs.picked.app/how-to/connect-the-mcp-server) for other tools.
