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

@basenative/notify

v3.3.0

Published

Email notifications via SMTP and SendGrid with template rendering

Readme

@basenative/notify

Email sending with HTML templates, in-app notifications, and SMTP/SendGrid/Resend transports

Part of the BaseNative ecosystem — a signal-based web runtime over native HTML.

Install

npm install @basenative/notify

Quick Start

import {
  renderEmail,
  createEmailSender,
  createSmtpTransport,
} from '@basenative/notify';

const transport = createSmtpTransport({
  host: 'smtp.example.com',
  port: 587,
  auth: { user: '[email protected]', pass: process.env.SMTP_PASS },
});

const sender = createEmailSender(transport);

const template = `
  <h1>Hello, {{ name }}!</h1>
  <p>Your account has been created. <a href="{{ link }}">Get started</a></p>
`;

const { html, text } = renderEmail(template, {
  name: 'Alice',
  link: 'https://example.com/onboarding',
});

await sender.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Welcome!',
  html,
  text,
});

In-App Notifications

import { createNotificationCenter } from '@basenative/notify';

const notifications = createNotificationCenter();

notifications.add({ type: 'info', message: 'Your report is ready.' });
notifications.add({ type: 'error', message: 'Payment failed.', persistent: true });

// Read all active notifications
const all = notifications.getAll();
notifications.dismiss(all[0].id);

API

Email

  • renderEmail(template, data) — Interpolates {{ variable }} placeholders in an HTML template. Returns { html, text } where text is a plain-text version derived from the HTML.
  • createEmailSender(transport) — Creates a sender bound to a transport. Returns { send(options) } where options are { to, from, subject, html, text? }.

Escaping

Every {{ variable }} value is HTML-escaped by default, using the same escapeAttr helper @basenative/server uses for SSR templates (@basenative/runtime/shared/escape). A value that contains <script> or other markup is rendered as inert text, not executable HTML:

renderEmail('<p>Hi {{ name }}</p>', { name: '<script>alert(1)</script>' });
// => { html: '<p>Hi &lt;script&gt;alert(1)&lt;/script&gt;</p>', ... }

To insert trusted HTML without escaping it, wrap the value in raw():

import { raw } from '@basenative/runtime/shared/escape';

renderEmail('<div>{{ body }}</div>', { body: raw('<strong>Bold</strong>') });
// => { html: '<div><strong>Bold</strong></div>', ... }

Only pass raw() around HTML you trust — it disables escaping entirely for that value, in every position the placeholder appears ({{ }} interpolation here has no idea whether it landed in a text node or an attribute value, so opting out of escaping opts out of both).

Transports

  • createSmtpTransport(options) — Sends email via SMTP. Options: host, port, secure, auth: { user, pass }.
  • createSendGridTransport(options) — Sends email via the SendGrid API. Options: apiKey.
  • createResendTransport(options) — Sends email via the Resend API. Options: apiKey.

In-App Notifications

  • createNotificationCenter() — Creates an in-app notification store.
    • .add(notification) — Adds a notification. Fields: type ('info', 'warn', 'error', 'success'), message, persistent?, metadata?. Returns the created notification with an auto-generated id.
    • .dismiss(id) — Removes a notification by ID.
    • .getAll() — Returns all active notifications.
    • .clear() — Removes all notifications.

License

Apache-2.0