npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@templatical/media-library

v0.64.1

Published

Media library management for Templatical email editor

Readme

@templatical/media-library

Media library for Templatical — composable, Vue components, and a standalone visual SDK.

npm version License

Browse, upload, organize, crop, and replace media assets. Used by @templatical/editor behind a MediaProvider (the editor bundles the Browse UI — you do not install this package for init({ media })), and available as a standalone SDK for any app that needs a media manager.

Install

npm install @templatical/media-library

Peer dep: vue@^3.5. Not needed next to @templatical/editor — that package already contains the modal.

Storage. The library is storage-agnostic. Pass a MediaProvider you implement. See the media contract.

Usage

Standalone visual SDK (mount anywhere)

import { init } from '@templatical/media-library';
import type { MediaLibraryConfig } from '@templatical/media-library';
import '@templatical/media-library/style.css';

const provider = {
  list: async () => ({ items: [] }),
  create: false,
  update: false,
  delete: false,
  folders: false,
  replace: false,
  importFromUrl: false,
  checkUsage: false,
  frequentlyUsed: false,
  storage: false,
} satisfies MediaLibraryConfig['provider'];

const container = document.createElement('div');
document.body.append(container);
const media = await init({
  container,
  provider,
  onSelect(asset) {
    console.log('Picked:', asset.url);
  },
});

// Later
media.unmount();

This provider opens an empty, read-only library. Replace list with your storage query to show assets. onSelect is optional. accept narrows categories; omit it for every category.

Vue component

Use MediaLibraryModal inside a Vue 3 app. See the media contract for the provider the modal sits on.

import { MediaLibraryModal } from '@templatical/media-library';
import '@templatical/media-library/style.css';
<MediaLibraryModal
  :visible="open"
  :provider="provider"
  :on-error="onError"
  @select="onSelect"
  @close="open = false"
/>

Composable (build your own UI)

import { useMediaLibrary } from '@templatical/media-library';
import type { MediaLibraryConfig } from '@templatical/media-library';

const provider = {
  list: async () => ({ items: [] }),
  create: false,
  update: false,
  delete: false,
  folders: false,
  replace: false,
  importFromUrl: false,
  checkUsage: false,
  frequentlyUsed: false,
  storage: false,
} satisfies MediaLibraryConfig['provider'];

const lib = useMediaLibrary({
  provider,
  onError(error) {
    console.error(error);
  },
});

This provider returns an empty, read-only library. See the media contract to connect your storage.

Exports

  • Standalone SDK — init(), unmount()
  • Vue components — MediaLibraryModal + 12 sub-components (grid, upload zone, folder tree, preview panel, edit/replace/import modals)
  • Composables — useMediaLibrary, useMediaCategories, useMediaPicker, useI18n
  • Types — MediaAsset, MediaFolder, MediaCategory, MediaRequestContext, MediaUsageInfo, MediaResult (re-exported from @templatical/types)

The MediaProvider / MediaAsset contract lives in @templatical/types.

Inside the editor's Shadow DOM

When the editor mounts in its default shadow-DOM mode (shadowDom: true), the media library invocation teleports into the editor's shadow-aware popover root rather than document.body. The MediaLibraryModal accepts an optional popoverTarget?: HTMLElement | null prop and provides it to its three nested sub-modals (replace, edit, import-url) so the entire media UI lives inside the editor's shadow root. Standalone-SDK consumers (init({ container })) mount at document.body.

If you embed MediaLibraryModal manually inside another shadow-DOM-mounted UI, pass popoverTarget to keep its sub-modals scoped to your shadow root.

Documentation

Full reference at docs.templatical.com.

License

MIT.