> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish an Extension

> Package and publish a Dynamic JavaScript SDK extension so other developers can install and use it.

A Dynamic extension is a regular npm package that exports one or more extension functions. The package should list `@dynamic-labs-sdk/client` as a peer dependency so consumers install a compatible version themselves.

## Package structure

```json theme={"system"}
{
  "name": "my-dynamic-extension",
  "version": "1.0.0",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "peerDependencies": {
    "@dynamic-labs-sdk/client": "^X.0.0"
  },
  "devDependencies": {
    "@dynamic-labs-sdk/client": "^X.0.0"
  }
}
```

Use your own build pipeline (`tsc`, `rollup`, `vite`, `tsdown`, etc.). Do not bundle `@dynamic-labs-sdk/client` into the published package; keep it as a peer dependency to avoid duplicate SDK instances.

## Publish

1. Build the package with your toolchain.
2. Run your test suite.
3. Publish to npm with `npm publish` (or your private registry).

## Use the extension

Consumers install both the Dynamic SDK and your package:

```bash theme={"system"}
npm install @dynamic-labs-sdk/client my-dynamic-extension
```

Then import and call the extension after `createDynamicClient`:

```typescript theme={"system"}
import { createDynamicClient } from "@dynamic-labs-sdk/client";
import { addMyExtension } from "my-dynamic-extension";

export const client = createDynamicClient({
  environmentId: "YOUR_ENVIRONMENT_ID",
});

addMyExtension();
```

If the package exports standalone functions, import them directly:

```typescript theme={"system"}
import { fetchMyData } from "my-dynamic-extension";

const data = await fetchMyData({ userId: "123" });
```

## Version compatibility

Keep `peerDependencies` aligned with the Dynamic SDK major version. The extension APIs may change between major versions, so consumers should upgrade both packages together.
