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

@leadrails/next

v0.1.3

Published

Next.js adapter for @leadrails/sdk. createLeadEventRoute + createLeadEventAction + ESLint lint preset.

Readme

@leadrails/next

Next.js adapter for @leadrails/sdk. Drop-in factories for Route Handlers and Server Actions, plus an opt-in lint preset that bans SDK imports from client-side files.

Install

pnpm add @leadrails/next @leadrails/sdk

Route Handler

// app/api/lead/route.ts
import { createLeadEventRoute } from "@leadrails/next";

type ContactForm = { name?: string; email?: string; feedback?: string };

export const POST = createLeadEventRoute({
  mapRequest: (body) => {
    const b = body as ContactForm;
    return {
      source: { source_system: "world-flags-feedback" },
      lead: {
        full_name: b.name,
        email:     b.email,
        message:   b.feedback,
      },
    };
  },
});

body is typed unknown — cast it to your form's shape inside mapRequest. The intake server validates the resulting LeadRails event.

The route reads LEADRAILS_* env vars by default; pass clientId / sourceId / keyId / signingSecret explicitly to override. If a required env var is missing, the route throws a LeadRailsConfigError at module-load time — your Next.js dev server will fail to start with a clear message.

Server Action

// app/actions.ts
"use server";
import { createLeadEventAction } from "@leadrails/next";

export const submitLead = createLeadEventAction({
  mapFormData: (fd) => ({
    source: { source_system: "my-app" },
    lead: {
      full_name: String(fd.get("name") ?? ""),
      email:     String(fd.get("email") ?? ""),
      message:   String(fd.get("message") ?? ""),
    },
  }),
});
// app/contact/page.tsx
import { submitLead } from "../actions";

export default function ContactPage() {
  return (
    <form action={submitLead}>
      <input name="name"    placeholder="Your name" />
      <input name="email"   placeholder="Email" type="email" />
      <textarea name="message" placeholder="Message" />
      <button type="submit">Send</button>
    </form>
  );
}

Lint preset (ESLint)

@leadrails/sdk ships three runtime/build guardrails (browser-stub exports, runtime typeof window check, and an independent NEXT_PUBLIC_* refusal); @leadrails/next adds a fourth (import "server-only") that fires inside Next.js Server Component bundles. The optional ESLint preset is a fifth layer that catches misuse in your editor before you even build.

// eslint.config.js
import leadrailsNext from "@leadrails/next/lint/eslint";

export default [
  ...leadrailsNext,
  // your other configs
];

The rule errors on @leadrails/sdk imports from any file NOT matching the conventional server-only paths:

  • app/api/**/route.{ts,tsx} (Next.js App Router handlers)
  • pages/api/**/*.{ts,tsx} (Next.js Pages Router handlers)
  • **/*.route.{ts,tsx}
  • **/actions.{ts,tsx} / **/*.action.{ts,tsx} / **/actions/**/*.{ts,tsx} (Server Actions)

oxlint: an oxlint config fragment ships at @leadrails/next/lint/oxlint as a JS module for future use, but oxlint doesn't yet support preset extension via .oxlintrc.json (as of v0.15). Use the ESLint preset for now; the oxlint shape is there for when oxlint enables it.

License

MIT