This demo project shows how to embed the Cloudinary Media Library widget into a web page using a Vite-based setup.
The widget lets you open Cloudinary's media library UI, select one or more assets, and then handle the selected assets in JavaScript (for example, logging them or inserting them into your app).
- Build tool: Vite
- Language: Vanilla JavaScript
- Install dependencies
npm install- Run the dev server
npm run dev- Open the app
Vite will print a local URL (usually http://localhost:5173). Open it in your browser to see the widget.
- The main logic lives in
src/index.js. - A Cloudinary media library instance is created with configuration options such as:
cloud_nameapi_keyinline_containerbutton_caption,button_classmax_files,insert_caption, and others
- An
insertHandlercallback receives the selectedassetsarray; in this demo, the assets are simply logged to the console.
- Update the options in
src/index.js(for example,cloud_name,api_key,max_files, captions, and container selectors) to match your own Cloudinary account and UI requirements. - Adapt the
insertHandlerto integrate the selected assets into your own application instead of just logging them.
npm run dev: Start the Vite development server.npm run build: Build the project for production.npm run preview: Preview the production build locally.