# @keepeek/keepicker-react

> ## Steps to use the Keepicker.

Latest version **1.28.1** (published 2026-10-28) · 0 weekly downloads

## Install

```sh
npm install @keepeek/keepicker-react
pnpm add @keepeek/keepicker-react
yarn add @keepeek/keepicker-react
bun add @keepeek/keepicker-react
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.28.1 |
| Published | 2026-10-28 |
| First published | 2023-10-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 67 |
| Unpacked size | 5.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Maintainers | rd-keepeek |

## Links

- npm: https://www.npmjs.com/package/@keepeek/keepicker-react
- npm.io page: https://npm.io/package/@keepeek/keepicker-react

## Dependencies (67)

- [yup](https://npm.io/package/yup.md) 0.32.11
- [zod](https://npm.io/package/zod.md) 3.22.4
- [clsx](https://npm.io/package/clsx.md) 1.1.1
- [uuid](https://npm.io/package/uuid.md) 8.3.2
- [axios](https://npm.io/package/axios.md) 0.34.0
- [dayjs](https://npm.io/package/dayjs.md) 1.10.8
- [react](https://npm.io/package/react.md) 19.0.0
- [tslib](https://npm.io/package/tslib.md) 2.3.1
- [formik](https://npm.io/package/formik.md) 2.2.9
- [lodash](https://npm.io/package/lodash.md) 4.18.1
- [recoil](https://npm.io/package/recoil.md) 0.7.7
- [i18next](https://npm.io/package/i18next.md) 21.6.12
- [@mui/lab](https://npm.io/package/@mui/lab.md) 5.0.0-alpha.177
- [dropzone](https://npm.io/package/dropzone.md) 6.0.0-beta.2
- [cropperjs](https://npm.io/package/cropperjs.md) 1.6.2
- [js-base64](https://npm.io/package/js-base64.md) 3.7.7
- [notistack](https://npm.io/package/notistack.md) 2.0.8
- [react-dnd](https://npm.io/package/react-dnd.md) 16.0.1
- [react-dom](https://npm.io/package/react-dom.md) 19.0.0
- [react-pdf](https://npm.io/package/react-pdf.md) 9.2.1
- [jwt-decode](https://npm.io/package/jwt-decode.md) 3.1.2
- [pdfjs-dist](https://npm.io/package/pdfjs-dist.md) 2.13.216
- [axios-retry](https://npm.io/package/axios-retry.md) 3.3.1
- [image-focus](https://npm.io/package/image-focus.md) 1.2.1
- [keycloak-js](https://npm.io/package/keycloak-js.md) 19.0.3
- [yup-locales](https://npm.io/package/yup-locales.md) 1.2.28
- [react-spring](https://npm.io/package/react-spring.md) 10.0.4
- [use-debounce](https://npm.io/package/use-debounce.md) 7.0.1
- [@mui/material](https://npm.io/package/@mui/material.md) 5.18.0
- [patch-package](https://npm.io/package/patch-package.md) 8.0.0
- [react-i18next](https://npm.io/package/react-i18next.md) 13.0.1
- [react-scripts](https://npm.io/package/react-scripts.md) 5.0.1
- [sanitize-html](https://npm.io/package/sanitize-html.md) 2.12.1
- [@emotion/react](https://npm.io/package/@emotion/react.md) 11.8.2
- [@emotion/styled](https://npm.io/package/@emotion/styled.md) 11.8.1
- [react-file-drop](https://npm.io/package/react-file-drop.md) 3.1.6
- [react-hook-form](https://npm.io/package/react-hook-form.md) 7.35.0
- [@keepeek/commons](https://npm.io/package/@keepeek/commons.md) 3.94.1
- [@mui/x-tree-view](https://npm.io/package/@mui/x-tree-view.md) 6.17.0
- [react-router-dom](https://npm.io/package/react-router-dom.md) 6.14.1
- [copy-to-clipboard](https://npm.io/package/copy-to-clipboard.md) 3.3.3
- [html-react-parser](https://npm.io/package/html-react-parser.md) 3.0.16
- [react-html-parser](https://npm.io/package/react-html-parser.md) 2.0.2
- [@keepeek/api-client](https://npm.io/package/@keepeek/api-client.md) 2.108.0
- [@mui/icons-material](https://npm.io/package/@mui/icons-material.md) 5.18.0
- [@mui/x-date-pickers](https://npm.io/package/@mui/x-date-pickers.md) 7.29.4
- [react-error-boundary](https://npm.io/package/react-error-boundary.md) 6.1.2
- [react-zoom-pan-pinch](https://npm.io/package/react-zoom-pan-pinch.md) 2.6.1
- [@tanstack/react-table](https://npm.io/package/@tanstack/react-table.md) 8.9.3
- [react-canvas-confetti](https://npm.io/package/react-canvas-confetti.md) 1.3.0
- [react-h5-audio-player](https://npm.io/package/react-h5-audio-player.md) 3.8.3
- [@braintree/sanitize-url](https://npm.io/package/@braintree/sanitize-url.md) 6.0.4
- [axios-cache-interceptor](https://npm.io/package/axios-cache-interceptor.md) 1.3.1
- [cra-template-typescript](https://npm.io/package/cra-template-typescript.md) 1.1.3
- [react-dnd-html5-backend](https://npm.io/package/react-dnd-html5-backend.md) 16.0.1
- [react-responsive-masonry](https://npm.io/package/react-responsive-masonry.md) 2.2.0
- [@keepeek/refront-components](https://npm.io/package/@keepeek/refront-components.md) 8.4.3
- [@react-hook/resize-observer](https://npm.io/package/@react-hook/resize-observer.md) 1.2.6
- [@r2wc/react-to-web-component](https://npm.io/package/@r2wc/react-to-web-component.md) 2.0.3
- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) 0.2.2
- [react-lazy-load-image-component](https://npm.io/package/react-lazy-load-image-component.md) 1.6.2
- [@fortawesome/pro-light-svg-icons](https://npm.io/package/@fortawesome/pro-light-svg-icons.md) 6.6.0
- [@fortawesome/pro-solid-svg-icons](https://npm.io/package/@fortawesome/pro-solid-svg-icons.md) 6.6.0
- [i18next-browser-languagedetector](https://npm.io/package/i18next-browser-languagedetector.md) 7.1.0
- [@fortawesome/fontawesome-svg-core](https://npm.io/package/@fortawesome/fontawesome-svg-core.md) 6.6.0
- [@fortawesome/free-brands-svg-icons](https://npm.io/package/@fortawesome/free-brands-svg-icons.md) 6.6.0
- [@fortawesome/pro-regular-svg-icons](https://npm.io/package/@fortawesome/pro-regular-svg-icons.md) 6.6.0

## Recent versions

- 1.28.1 (latest) — 2026-10-28
- 1.28.1-beta.6 (beta) — 2026-11-19
- 1.7.1 (release-1.7.x) — 2024-10-25
- 1.28.1-beta.5 — 2026-11-17
- 1.28.1-beta.4 — 2026-11-10
- 1.28.1-beta.3 — 2026-10-28
- 1.28.1-beta.2 — 2026-10-27
- 1.28.1-beta.1 — 2026-10-27
- 1.28.0 — 2026-10-22
- 1.27.1 — 2026-10-22
- 1.27.0-beta.6 — 2026-10-14
- 1.27.0-beta.5 — 2026-10-01
- 1.27.0-beta.4 — 2026-09-30
- 1.27.0-beta.3 — 2026-09-21
- 1.27.0 — 2026-09-17
- … 150 more at https://npm.io/package/@keepeek/keepicker-react/versions

## README

# Integration

## Steps to use the Keepicker.

### Import the JavaScript file registering kpk-keepicker web component:

```html
<head>
  <script
    async
    src="https://cdn.jsdelivr.net/npm/@keepeek/keepicker-react@1/dist/index.js"
  ></script>
</head>
```

### Add the web component tag in the DOM:

```html
<body>
  <kpk-keepicker
    id="keepicker"
    keycloak-client-id="XXX"
    api-endpoint="XXX"
    data-locale="FR"
    ui-locale="FR"
  ></kpk-keepicker>
</body>
```

### Add a callback that will be triggered when selecting an asset:

```html
<script>
  document
    .querySelector("#keepicker")
    .addEventListener("kpk-insert", (event) => {
      console.log(event.detail);
    });
  document
    .querySelector("#keepicker")
    .addEventListener("kpk-insert-link", (event) => {
      console.log(event.detail);
    });
</script>
```

### Use the events to insert content

Keepicker events are triggered for all asset types: pictures, videos, audio files, documents and other assets. Below are some examples of event content.

#### Event for a picture

`kpk-insert` event detail will contain the following JSON content for a picture:

```json
{
  "element": {
    "id": 123,
    "title": {
      "id": "title",
      "type": "TEXT",
      "name": "Title",
      "value": "Media title"
    },
    "originalFileName": "123.jpg",
    "previewUrl": "https://keepeek.com/previewUrl.jpg",
    "fields": [
      {
        "id": "title",
        "type": "TEXT",
        "name": "Title",
        "value": "Media title"
      },
      { "id": "...", "type": "...", "name": "...", "value": "..." }
    ],
    "permalinks": [
      {
        "title": "whr",
        "description": "...",
        "url": "https://keepeek.com/permanentPreviewUrl.jpg"
      },
      {
        "title": "...",
        "description": "...",
        "url": "..."
      }
    ],
    "imagesServiceUrl": "kpk://dynameek-kpk/1200/bwb6bw8xrm.jpg",
    "imagesServicePermalinks": "kpkp://dynameek-kpk/1200/g9g0wtj8ky.jpg",
    "...": "..."
  }
}
```

To get a picture, use the following code:

```js
const url = event.detail.element.permalinks.find(
  (permalink) => permalink.title === "whr",
)?.url;
```

#### Event for a video

`kpk-insert` event detail will contain the following JSON content for a video:

```json
{
  "element": {
    "id": 123,
    "title": {
      "id": "title",
      "type": "TEXT",
      "name": "Title",
      "value": "Media title"
    },
    "previewUrl": "https://keepeek.com/previewUrl.jpg",
    "fields": [
      {
        "id": "title",
        "type": "TEXT",
        "name": "Title",
        "value": "Media title"
      },
      {
        "id": "...",
        "type": "...",
        "name": "...",
        "value": "..."
      }
    ],
    "mediaType": "video/mp4",
    "permalinks": [
      {
        "title": "preview",
        "description": "...",
        "url": "https://keepeek.com/permanentPreviewVideo.mp4"
      },
      {
        "title": "...",
        "description": "...",
        "url": "..."
      }
    ],
    "...": "..."
  }
}
```

To get preview video, use the following code:

```js
const url = event.detail.element.permalinks.find(
  (permalink) => permalink.title === "preview",
)?.url;
```

#### Event for a generated picture

`kpk-insert-link` event detail will contain the following JSON content for a generated picture:

```json
{
  "element": {
    "id": 123,
    "title": {
      "id": "title",
      "type": "TEXT",
      "name": "Title",
      "value": "Media title"
    },
    "fields": [
      {
        "id": "title",
        "type": "TEXT",
        "name": "Title",
        "value": "Media title"
      },
      {
        "id": "...",
        "type": "...",
        "name": "...",
        "value": "..."
      }
    ],
    "permalinks": [
      {
        "title": "...",
        "description": "...",
        "url": "..."
      }
    ],
    "imagesServiceUrl": "kpk://dynameek-kpk/1200/bwb6bw8xrm.jpg",
    "imagesServicePermalinks": "kpkp://dynameek-kpk/1200/b9g0wtj8ky.jpg",
    "...": "..."
  },
  "link": "https://keepeek.com/generatedPictureUrl.jpg"
}
```

In this example, the `imagesServiceUrl` and `imagesServicePermalinks` keys contain the picture URLs used to call the Dynameek service. `imagesServiceUrl` is used to target the current picture version, while `imagesServicePermalinks` always points to the last picture version.

To get generated picture, use the following code:

```js
const url = event.detail.link;
```

## Examples

### React

```jsx
function App() {
  const ref = useRef();

  useEffect(() => {
    if (ref && ref.current) {
      const currentRef = ref.current;
      const handleInsert = (event) => console.log(event.detail.element);
      currentRef.addEventListener("kpk-insert", handleInsert);
      return () => {
        currentRef.removeEventListener("kpk-insert", handleInsert);
      };
    }
  }, []);
  return (
    <div className="App">
      <kpk-keepicker
        ref={ref}
        keycloak-client-id="XXX"
        api-endpoint="XXX"
        data-locale="FR"
        ui-locale="FR"
      ></kpk-keepicker>
    </div>
  );
}
```

### Drupal form

To integrate component in a form, add a container:

```jsx
$form['container']['picker'] = [
  '#type' => 'container',
  '#attributes' => array('id'=>'kpk-keepicker-container'),
];
```

Add a behaviour to mount web component:

```jsx
Drupal.behaviors.addKeepickerWebComponentMarkup = {
  attach: function (context) {
    if (context.id === "node-article-edit-form") {
      document.querySelector("#kpk-keepicker-container").innerHTML =
        '<kpk-keepicker id="keepicker" keycloak-client-id="XXX" api-endpoint="XXX" data-locale="FR" ui-locale="FR"></kpk-keepicker>';
      document
        .querySelector("#keepicker")
        .addEventListener("kpk-insert", (event) => {
          document.querySelector(".keepicker-url").value =
            event.detail.element.previewUrl;
        });
    }
  },
};
```

## List of attributes

| Name               | Mandatory | Type   | Default value               | Description                                                                                       |
| ------------------ | --------- | ------ | --------------------------- | ------------------------------------------------------------------------------------------------- |
| api-endpoint       | no        | String |                             | API Endpoint<br/>If not provided, the user will need to enter the Keepeek instance URL to connect |
| keycloak-client-id | no        | String | Default Keepicker Client ID | Keycloak Client ID                                                                                |
| keycloak-idp       | no        | String | FR                          | Keycloak IDP to add a SSO button                                                                  |
| data-locale        | no        | String | FR                          | Data locale                                                                                       |
| ui-locale          | no        | String | FR                          | Interface locale                                                                                  |

## List of events

| Name            | Description                                        |
| --------------- | -------------------------------------------------- |
| kpk-insert      | Event dispached when inserting one element         |
| kpk-insert-link | Event dispached when inserting a generated picture |

---
_Source: https://npm.io/package/@keepeek/keepicker-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
