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

strapi-plugin-smart-preview

v1.0.1

Published

A Smart Preview plugin for Strapi v4/v5 that injects a configurable preview button into the Content Manager edit view.

Readme

Strapi Plugin: Smart Preview

A production-ready plugin for Strapi v4 / v5 that injects a "Smart Preview" button directly into the Content Manager's edit view. It dynamically uses the current content type and entry ID to build a configurable preview URL, allowing content editors to easily preview their work on your frontend.

✨ Features

  • Dynamic Preview URLs — Constructs <basePreviewUrl>?type=<contentType>&id=<id> automatically.
  • Works for ANY Content Type — Automatically identifies the current Collection Type or Single Type UID.
  • Save-Aware — The button is disabled until the entry is saved (an ID is generated). Tooltips inform the user.
  • Configurable — Set the base preview URL via Strapi plugin config or environment variables.
  • Token Support — Optionally pass a token query parameter for secure preview endpoints.
  • Zero Dependencies — Uses only Strapi's built-in design system and React.

📦 Installation

npm install strapi-plugin-smart-preview
# or
yarn add strapi-plugin-smart-preview

⚙️ Configuration

Enable the plugin in your config/plugins.js (or .ts):

module.exports = ({ env }) => ({
  'smart-preview': {
    enabled: true,
    config: {
      previewBaseUrl: env('PREVIEW_BASE_URL', 'http://localhost:3000/preview'),
      previewToken: env('PREVIEW_TOKEN', null),
    },
  },
});

Environment Variables

| Variable | Description | Default | | ------------------- | ------------------------------------ | -------------------------------- | | PREVIEW_BASE_URL | Base URL for the preview endpoint | http://localhost:3000/preview | | PREVIEW_TOKEN | Optional token for secure previews | null |

🚀 Usage

  1. Install the plugin and configure it as shown above.
  2. Start your Strapi server (npm run develop).
  3. Navigate to Content Manager.
  4. Open an existing entry or create a new one.
  5. Save the entry if it's new.
  6. Click the Smart Preview button located on the right side of the edit view.

The button opens a new tab with:

<previewBaseUrl>?type=<content-type-uid>&id=<entry-id>&token=<optional-token>

🔧 How It Works

The plugin:

  1. Registers itself with Strapi's plugin system during register().
  2. Injects a PreviewButton React component into the Content Manager's edit view via bootstrap().
  3. The button reads the current URL to determine the content type UID and entry ID.
  4. On click, it builds a preview URL using the configured base URL and opens it in a new tab.
  5. The base URL is fetched from the server-side config, which merges plugin config and env variables.

📋 Compatibility

| Strapi Version | Supported | | -------------- | --------- | | v5.x | ✅ | | v4.x | ✅ | | v3.x | ❌ |

📄 License

MIT — Made with ❤️ by Techexplified