# Installation

> Add photocn to a React project that uses shadcn/ui.

## 1. Set up shadcn/ui

photocn is built on the [Base UI](https://base-ui.com) version of shadcn/ui, the default for new projects:

```bash
npx shadcn@latest init -b base
```

Already have a project? Check that the `style` in your `components.json` starts with `base-` (for example `base-nova`).

## 2. Add the editor

```bash
npx shadcn@latest add @photocn/image-editor
```

`@photocn` is listed in the [shadcn registry directory](https://ui.shadcn.com/docs/directory), so the CLI finds it with no setup.

This installs the `photocn` package, the shadcn/ui components the editor needs, and the editor files in `components/image-editor/`.

## 3. Use it

```tsx
import { ImageEditor } from "@/components/image-editor/image-editor";

export default function Page() {
  return <ImageEditor className="h-dvh" src="/photo.jpg" />;
}
```

The editor is a client component. `src` can be a URL, a `File`, a `Blob`, an `ArrayBuffer` or an `<img>`. Images from other domains need CORS headers.

## Only need some pieces?

Every piece can be installed on its own:

```bash
npx shadcn@latest add @photocn/image-editor-canvas @photocn/image-editor-filters @photocn/image-editor-export
```

## Content-Security-Policy

The renderer runs in a Web Worker started from a `blob:` URL, so no bundler setup is needed. If your CSP blocks `worker-src blob:`, start the worker yourself:

```tsx

    new Worker(new URL("photocn/worker/entry", import.meta.url), { type: "module" })
  }
/>
```
