Skip to main content
This guide covers setting up and using the @fluid-app/dam-picker npm package to embed Fluid’s Digital Asset Management (DAM) file picker into your application. The SDK provides a drop-in modal for browsing, searching, and uploading assets, with support for React and vanilla JavaScript.

Overview

The DAM Picker SDK lets you add a full-featured asset picker to any web application. Users can browse the DAM library, upload files from their computer, import from URLs, and search Unsplash — all within a single modal. When a user makes a selection, your application receives structured asset data including the public URL, asset code, MIME type, and optional metadata. The SDK works with any frontend framework. First-class React bindings are included, and the vanilla JavaScript API integrates cleanly with Vue, Angular, Svelte, or plain HTML pages.

Installation

Install the package from npm using your preferred package manager:

Prerequisites

You need a Fluid API token to authenticate the picker. This is the same token used for other Fluid API integrations. See the Authentication guide for details on obtaining a token.

Quick Start

Choose the integration style that matches your stack.

Configuration

DamPicker Options

The DamPicker constructor and DamPickerModal component accept the following options:

Asset Type Filtering

Restrict the picker to specific asset types using the filters.assetTypes option:
Available asset types:

Multi-Select

By default, users can select one asset at a time. Set maxSelectable to allow multiple selections:
With the React component:
onSelect always receives an array of SelectedAsset[], even when maxSelectable is 1. For single-select, access the asset with assets[0].

Selected Asset Structure

When a user makes a selection, onSelect receives an array of SelectedAsset objects:

Example: Using the Selected Asset

Error Handling

The onError callback receives a DamPickerError with a machine-readable code and a human-readable message:

Instance Methods

The DamPicker class exposes these methods: Always call destroy() when you’re done with the picker to prevent memory leaks:

Upload Behavior

When users upload a file (either from their computer or via URL), the file is uploaded to Fluid’s DAM. Once the upload completes, the onSelect callback fires with the new asset — no separate upload handling is needed. The picker automatically closes after a successful upload.

Framework Integrations

The vanilla JavaScript API works with any framework. These examples show common integration patterns — create the picker on mount and call destroy() on teardown.

Common Use Cases

Product Image Selector

Document Attachment

Local Development

For local development, point the SDK to your local fluid-admin instance:

Troubleshooting

Picker does not open

  • Verify your API token is valid and not expired. An invalid token triggers the onError callback with AUTHENTICATION_ERROR.
  • Check the browser console for JavaScript errors.
  • Ensure the @fluid-app/dam-picker package is installed and imported correctly.

Picker opens but shows a blank screen

  • Check network connectivity. The picker loads inside an iframe from admin.fluid.app.
  • If using a corporate network or VPN, ensure admin.fluid.app is not blocked.
  • The onReady callback should fire when the picker is loaded. If it doesn’t, there may be a network issue.

Timeout errors

  • The picker has a 10-second load timeout. On slow connections, this may not be enough.
  • Check that admin.fluid.app is reachable from the browser.

onSelect returns an empty array

  • This should not happen under normal operation. If it does, check the browser console for errors and ensure you’re on the latest SDK version.

Multi-select not working

  • Confirm you’re passing maxSelectable with a value greater than 1.
  • The picker UI will show a different selection mode when maxSelectable > 1.

Content Security Policy (CSP) issues

If your application uses a strict CSP, you need to allow the picker iframe:
For local development: