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

@gavinrigs/decap-nunjucks-preview

v1.0.2

Published

Renders Decap CMS previews with the site's own Nunjucks templates, filters and stylesheets.

Readme

@gavinrigs/decap-nunjucks-preview

Renders the Decap CMS preview pane with the site's own Nunjucks templates, filters, globals and stylesheets, so the editor sees the real page rather than a hand-maintained React approximation.

Registering

import CMS from "decap-cms-app";
import { register } from "@gavinrigs/decap-nunjucks-preview";

register(CMS, {
  collections: {
    posts: "reactive",
    templates: "dynamic",
  },
  styles: ["/css/main.css"],
  filters: { readableDate, slug },
  globals: { relation2Resolve },
  wrapper: {
    bodyClass: "bg-site min-h-screen flex flex-col",
    mainClass: "flex-1",
    fonts: ["https://fonts.googleapis.com/css2?family=Lora&display=swap"],
  },
});

Preview types

| Type | Behaviour | | --- | --- | | reactive | Renders the Nunjucks template stored in the entry's template field (fetched by a resolved widget such as hiddenfetch), against the entry's own data plus any resolved data. | | dynamic | Renders the template and test_data code fields stored directly on the entry — used for editing templates themselves. |

Options

| Option | Default | Purpose | | --- | --- | --- | | collections | {} | Collection name → preview type. | | styles | [] | Stylesheet URLs injected into the preview pane. | | filters | {} | Nunjucks filters. A luxon-backed date filter is always registered. | | globals | {} | Nunjucks globals. | | componentTemplates | {} | Inline template sources so {% include %} resolves in the browser, which has no filesystem. | | wrapper | {} | Page chrome reproduced around the output: bodyClass, mainClass, mainId, headHtml, fonts. | | resolvedWidgets | ["relation2","hiddenfetch"] | Widget names whose data comes from an entry-data provider. | | templateField | "cms_template" | Field holding the template for reactive collections. | | uploadFolders | ["/images","/images/uploads"] | Media folders indexed when previewing unsaved uploads. | | CMS | bundled decap-cms-app | Decap instance to register against. |

wrapper

Templates normally {% extends %} a base layout that the preview cannot load, so the extends tag is stripped and this wrapper stands in for it. Supply the same classes the site's <body> and <main> use so the site's CSS matches. fonts is expanded into preconnect hints plus stylesheet links; anything more specific goes in headHtml.

Behaviour worth knowing

  • Images not yet saved are rewritten to blob URLs before injection, so the browser never requests a path that does not exist yet.
  • Cross-context updates: the preview runs in its own iframe JS context, so resolved data arrives over the core message bus and is cached locally; the same-context path is preferred when available.
  • Lucide icons in rendered output are hydrated after each render.

Security assumption

Rendered template output is injected with dangerouslySetInnerHTML, because the whole point is to show the real markup a template produces — escaping it would defeat that. This is safe only under the assumption that both the templates and the entry data come from authenticated CMS editors you already trust with the content of the site. Do not point this preview at templates or data from an untrusted source; there is no sanitisation step.

Dependencies

  • @gavinrigs/decap-plugin-core
  • Peer: decap-cms-app, nunjucks, luxon, lucide, react

Works without any widget plugin installed; it simply has no resolved data to merge.