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

astro-svg-lens

v0.1.1

Published

Astro Dev Toolbar app for previewing and copying SVG asset imports.

Readme

astro-svg-lens focuses on developer visibility. It does not replace Astro's official SVG component support; it helps you find the SVG asset you already have and copy the import you need.

Features

  • Scan SVG files from configurable project directories
  • Preview optimized SVGs in the Astro Dev Toolbar (scripts and event handlers are stripped before rendering)
  • Search SVGs by file name or project path
  • Browse SVGs grouped by directory
  • Copy component imports, raw imports, and project-relative paths — public/ assets get URL usage instead
  • Refresh automatically when SVG files are added, changed, or removed
  • Keep SVG rendering behavior in Astro's official SVG pipeline

Installation

Add the integration with Astro's setup command:

pnpm astro add astro-svg-lens

Or install it manually:

pnpm add -D astro-svg-lens
npm install -D astro-svg-lens
yarn add -D astro-svg-lens

Usage

Add the integration to your Astro config:

// astro.config.mjs
import { defineConfig } from "astro/config";
import svgLens from "astro-svg-lens";

export default defineConfig({
  integrations: [
    svgLens({
      dirs: ["src", "public"],
    }),
  ],
});

Start Astro in dev mode and open the Astro Dev Toolbar. The SVG Lens panel will show matching SVG files.

Options

interface SvgLensOptions {
  /**
   * Directories to scan, relative to the Astro project root.
   * Defaults to ["src", "public"].
   */
  dirs?: string[];

  /**
   * Enable the Astro Dev Toolbar app.
   * Defaults to true.
   */
  toolbar?: boolean;
}

Examples

Scan common source and public asset folders:

svgLens({
  dirs: ["src/assets", "src/icons", "public"],
});

Disable the toolbar while keeping the integration installed:

svgLens({
  toolbar: false,
});

What It Copies

For an SVG at src/icons/home.svg, SVG Lens copies root-absolute import snippets that work in any Astro project without path aliases:

import HomeIcon from "/src/icons/home.svg";
import homeSvg from "/src/icons/home.svg?raw";

The component import uses Astro's built-in SVG component support and can be rendered in .astro and MDX files. The ?raw import uses Astro's underlying Vite asset handling when the SVG source string is needed. Astro SVG components are not directly renderable inside UI framework components such as React or Svelte.

Files under public/ are static assets and cannot be imported as modules, so SVG Lens offers URL-based usage for them instead. For public/logo.svg:

/logo.svg
<img src="/logo.svg" alt="logo" />

It also exposes the project-relative path:

src/icons/home.svg

What This Package Does Not Do

astro-svg-lens does not transform SVG files into components itself.

Modern Astro already supports importing SVG files as components, so this package intentionally stays focused on discovery: scanning, previewing, searching, and copying import snippets from the Dev Toolbar.

License

MIT