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

@kreativa/email-client

v1.0.1

Published

Type-safe client SDK for Kreativa Email Service

Readme

@kreativa/email-client

Type-safe client SDK for Kreativa Email Service.

Installation

npm install @kreativa/email-client

Quick Start

Basic Usage (Runtime Validation)

import { createEmailClient } from '@kreativa/email-client';

const email = await createEmailClient({
  baseUrl: 'https://email.yoursite.com',
  apiKey: process.env.EMAIL_API_KEY!,
});

// Send an email - params are validated at runtime
await email.send('welcome', {
  to: '[email protected]',
  params: {
    name: 'John',
    actionUrl: 'https://example.com/verify',
  },
});

Typed Usage (Compile-Time + Runtime Validation)

First, sync types from your email service:

npx @kreativa/email-client sync \
  --url https://email.yoursite.com \
  --api-key $EMAIL_API_KEY \
  --output ./src/generated/email-types.ts

Then use the typed client:

import { createTypedEmailClient } from '@kreativa/email-client';
import type { TemplateMap } from './generated/email-types';

const email = await createTypedEmailClient<TemplateMap>({
  baseUrl: 'https://email.yoursite.com',
  apiKey: process.env.EMAIL_API_KEY!,
});

// Full autocomplete and type checking!
await email.send('welcome', {
  to: '[email protected]',
  params: {
    name: 'John',        // TypeScript knows this is required
    actionUrl: '...',    // TypeScript knows this is required
  },
});

CLI Commands

sync

Fetch TypeScript types from the email service:

npx @kreativa/email-client sync \
  --url <service-url> \
  --api-key <api-key> \
  --output <output-path>

check

Test connection and list available templates:

npx @kreativa/email-client check \
  --url <service-url> \
  --api-key <api-key>

API Reference

createEmailClient(config)

Creates an email client with runtime validation.

const client = await createEmailClient({
  baseUrl: string;      // Email service URL
  apiKey: string;       // API key for authentication
  fetchSchemas?: boolean; // Fetch schemas on init (default: true)
});

createTypedEmailClient<TTemplates>(config)

Creates a typed email client with compile-time type checking.

import type { TemplateMap } from './generated/email-types';

const client = await createTypedEmailClient<TemplateMap>({
  baseUrl: string;
  apiKey: string;
});

client.send(templateSlug, options)

Send an email using a template.

await client.send('template-slug', {
  to: '[email protected]',  // or ['[email protected]', '[email protected]']
  params: { ... },              // Template variables
  subject?: 'Override subject', // Optional subject override
});

client.getTemplates()

Get all available templates.

client.refreshSchemas()

Refresh template schemas from the service.

Error Handling

import { EmailValidationError, EmailApiError } from '@kreativa/email-client';

try {
  await email.send('welcome', { to: '...', params: {} });
} catch (error) {
  if (error instanceof EmailValidationError) {
    console.log('Missing params:', error.missingParams);
  } else if (error instanceof EmailApiError) {
    console.log('API error:', error.statusCode, error.message);
  }
}

License

MIT