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 🙏

© 2025 – Pkg Stats / Ryan Hefner

merchify

v0.1.9

Published

Merchify Javascript SDK for product mockups and print-on-demand

Readme

merchify

JavaScript/TypeScript SDK for product mockups and print-on-demand

Merchify provides a simple SDK for fetching product data and generating real-time merchandise mockups. Use it to visualize artwork on t-shirts, posters, mugs, and more.

Installation

npm install merchify
# or
yarn add merchify
# or
pnpm add merchify

Quick Start

import { getProduct, listProducts, generateMockupUrl } from 'merchify';

// Fetch a product by ID
const product = await getProduct('BEEB77');
console.log(product.name); // "Bella + Canvas 3001 Unisex Jersey Short Sleeve Tee"

// List all products
const products = await listProducts({ limit: 10 });
console.log(`Found ${products.length} products`);

// Generate a mockup URL
const mockupUrl = generateMockupUrl({
  productId: 'BEEB77',
  variantId: 'white-sm',
  artworkUrl: 'https://example.com/artwork.png',
  placement: 'Front',
  alignment: 'center'
});
console.log(mockupUrl); // URL to mockup image

Configuration

Configure the SDK to point to your Merchify endpoint:

import { config } from 'merchify';

config({
  endpoint: 'https://api.merchify.com',
  mockupUrl: 'https://mockup.merchify.com',
  accountId: 'your-account-id',
  mode: 'live' // or 'mock' for development
});

Environment Variables (Next.js):

NEXT_PUBLIC_MERCHIFY_ENDPOINT=https://api.merchify.com
NEXT_PUBLIC_MERCHIFY_MOCKUP_URL=https://mockup.merchify.com
NEXT_PUBLIC_MERCHIFY_ACCOUNT_ID=your-account-id

The SDK automatically reads these environment variables if not configured explicitly.

Core Functions

Product Data

// Get a single product
const product = await getProduct(productId: string, options?: {
  endpoint?: string;
  mode?: 'mock' | 'live' | 'meilisearch';
});

// List products
const products = await listProducts(options?: {
  limit?: number;
  offset?: number;
  endpoint?: string;
  mode?: 'mock' | 'live' | 'meilisearch';
});

Product Object Structure:

{
  id: string;              // Product ID (e.g., "BEEB77")
  name: string;            // Product name
  description?: string;    // Product description
  basePrice: number;       // Base price in cents
  variants: Variant[];     // Color/size variants
  placements: Placement[]; // Print areas (Front, Back, etc.)
  mockup: {
    blankUrl: string;      // Blank product image URL
  };
}

Mockup Generation

import { generateMockupUrl } from 'merchify';

const url = generateMockupUrl({
  productId: string;          // Required: Product ID
  variantId?: string;         // Optional: Specific variant (color/size)
  artworkUrl: string;         // Required: URL to artwork image
  placement?: string;         // Optional: Print area (default: 'Front')
  alignment?: ImageAlignment; // Optional: How to position artwork
  mode?: 'mock' | 'live';     // Optional: Mock or live rendering
});

// ImageAlignment options:
// 'center' | 'top' | 'bottom' | 'left' | 'right' |
// 'far-left' | 'far-right' | 'far-top' | 'far-bottom'

React Hooks (Optional)

For React applications, use the React-specific exports:

import { useRealtimeMockup } from 'merchify/react';

function MyComponent() {
  const { mockupUrl, isGenerating } = useRealtimeMockup({
    productId: 'BEEB77',
    artworkUrl: artwork.src,
    placement: 'Front',
    alignment: 'center'
  });

  return <img src={mockupUrl} alt="Product mockup" />;
}

TypeScript Support

Full TypeScript definitions are included. Import types:

import type {
  CatalogProduct,
  Variant,
  Placement,
  ImageAlignment
} from 'merchify';

Development Mode

Use mock mode for development without API calls:

config({ mode: 'mock' });

// Returns mock product data
const product = await getProduct('BEEB77');

API Reference

See full API documentation at: https://docs.merchify.com/sdk

React Components

For pre-built React components, install merchify-ui:

npm install merchify-ui

See: merchify-ui on npm

Examples

Support

License

MIT © driuqzy


Built for developers. Optimized for LLMs. 🤖

This SDK is designed to work seamlessly with AI coding assistants like Claude, GitHub Copilot, and Cursor. Clear types, explicit examples, and predictable patterns make it easy for LLMs to generate correct code.