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

medusa-plugin-product-description

v1.1.1

Published

Medusa v2 plugin to generate AI-powered product descriptions via OpenRouter.

Readme

medusa-plugin-product-description

AI-powered product & category description generator plugin for MedusaJS v2.

This plugin uses AI (via OpenRouter) to generate SEO-optimized descriptions for products and categories in Spanish. It adds widgets on the product and category detail pages, plus a dedicated admin page for batch operations and cache management.

Features

  • Product detail widget: "Generar Descripcion con IA" button directly on the product edit page
  • Category detail widget: "Generar Descripcion de Categoria con IA" button directly on the category edit page
  • Admin page "IA Descripciones": individual generation for products and categories, batch generation of ALL products/categories, and cache revalidation
  • AI generation via OpenRouter (OpenAI-compatible API, supports any model: Google Gemini, GPT, Claude, etc.)
  • Configurable prompts via environment variables
  • Automatic date stamp: "Descripcion actualizada el DD/MM/AAAA"
  • Server-side cache revalidation via STOREFRONT_URL
  • Batch operations with progress bar and cost warning
  • Zero hardcoded URLs — works on any Medusa installation

Prerequisites

  • MedusaJS v2.22.2 or later
  • Node.js v22.22.0 or later
  • An OpenRouter API key (free tier available)

Installation

npm install medusa-plugin-product-description

Configuration

1. Environment Variables

Add the following to your Medusa project's .env file:

OPENROUTER_API_KEY=sk-or-v1-your-key-here
OPENROUTER_MODEL=google/gemma-3-12b-it:free
OPENROUTER_SITE_URL=https://your-store.com
OPENROUTER_APP_NAME=Your Store Admin
STOREFRONT_URL=https://your-storefront.com
AI_DESCRIPTION_PROMPT=Genera una descripcion atractiva, natural y optimizada para SEO sobre el producto "{productTitle}". ...
AI_CATEGORY_PROMPT=Escribe una descripcion breve, natural y optimizada para SEO en Markdown sobre la categoria **{categoryName}**. ...

| Variable | Required | Default | Description | |---|---|---|---| | OPENROUTER_API_KEY | Yes | — | OpenRouter API key (sign up at openrouter.ai) | | OPENROUTER_MODEL | No | google/gemma-3-12b-it:free | Model to use. Browse models | | OPENROUTER_SITE_URL | No | — | Your site URL (sent as HTTP-Referer header) | | OPENROUTER_APP_NAME | No | Medusa Admin | Your app name (sent as X-Title header) | | STOREFRONT_URL | No | — | Your storefront base URL for cache revalidation (e.g. https://tustore.com) | | AI_DESCRIPTION_PROMPT | No | Default prompt (see below) | Prompt template for products. Use {productTitle} as placeholder | | AI_CATEGORY_PROMPT | No | Default prompt (see below) | Prompt template for categories. Use {categoryName} as placeholder |

Default product prompt:

Genera una descripcion atractiva, natural y optimizada para SEO sobre el producto "{productTitle}".
Debe parecer redactada por un humano y no mostrar rastros de IA.
Incluye iconos emoji de forma moderada y utiliza formato en Markdown.

La descripcion debe estar lista para publicarse directamente, sin frases introductorias, anotaciones ni indicaciones.
90-140 palabras.

Default category prompt:

Escribe una descripcion breve, natural y optimizada para SEO en Markdown sobre la categoria **{categoryName}**.
Incluye 2-4 emojis pertinentes (sin abusar).

Requisitos:
- 90-140 palabras.
- Tono cercano, profesional y claro.
- Nada de instrucciones meta ni disculpas; texto final listo para publicar.

2. Medusa Configuration

In your medusa-config.ts, register the plugin:

import { defineConfig } from "@medusajs/framework/config"

export default defineConfig({
  plugins: [
    {
      resolve: "medusa-plugin-product-description",
      options: {},
    },
  ],
})

Usage

Widgets (recommended)

The plugin injects widgets directly into the Medusa admin:

  • Product detail page (/app/products/:id): A "Generar Descripcion con IA" section appears below the product details. Generate, edit, save, and revalidate — all without leaving the page.
  • Category detail page (/app/categories/:id): Same widget for categories, with sibling category context for better AI results.

Admin Page: IA Descripciones

Navigate to IA Descripciones in the sidebar for advanced operations:

Individual generation:

  • Enter a product or category ID, load it, generate a description, edit and save.

Batch generation:

  • Generate descriptions for ALL products or ALL categories in one go.
  • A progress bar shows real-time status.
  • ⚠️ Warning: This calls the OpenRouter API for every entity. Use with caution — it may consume significant API credits.

Cache management:

  • Revalidate products cache, categories cache, or both at once.
  • Requires STOREFRONT_URL environment variable pointing to your storefront.

Next.js Revalidation Endpoint

If you're using a Next.js storefront, this plugin calls {STOREFRONT_URL}/api/revalidate?tags=... to revalidate the ISR cache. Add this endpoint:

// frontend/src/app/api/revalidate/route.ts
import { revalidateTag } from "next/cache"
import { NextRequest, NextResponse } from "next/server"

export async function GET(request: NextRequest) {
  const tag = request.nextUrl.searchParams.get("tags") || "products"
  revalidateTag(tag)
  return NextResponse.json({ revalidated: true, tag })
}

API Endpoints

POST /admin/ai-description

Generate a product description.

Request:

{ "productId": "prod_01JABC...", "productTitle": "Paracetamol 650mg" }

Response:

{ "description": "## Paracetamol 650mg\n\nAlivia el dolor y la fiebre con..." }

POST /admin/ai-category-description

Generate a category description. Optionally include sibling category names for context.

Request:

{
  "categoryId": "pcat_01JABC...",
  "categoryName": "Analgesicos",
  "relatedCategories": ["Antiinflamatorios", "Antigripales"]
}

Response:

{ "description": "## Analgesicos\n\nEncuentra los mejores analgesicos..." }

POST /admin/revalidate-cache

Trigger cache revalidation on the storefront. Requires STOREFRONT_URL environment variable.

Request:

{ "tags": "products" }

Response:

{ "revalidated": true, "tags": "products" }

Development

# Install dependencies
npm install

# Build the plugin
npm run build

# Watch mode (for local plugin development)
npm run dev

Local Testing with a Medusa Project

# From your plugin directory
npm run dev

# In your Medusa project directory:
npx medusa plugin:add ../path-to/medusa-plugin-product-description

Publishing to NPM

npx medusa plugin:build
npm publish

To publish an update:

npm version patch   # or minor / major
npx medusa plugin:build
npm publish

License

MIT