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

@wekivo/next

v0.1.1

Published

SDK Next.js pour Kivo — Provider RSC-safe + helper serveur Edge-compatible.

Readme

@wekivo/next

SDK Next.js officiel pour Kivo. Couvre App Router (RSC, Server Actions, Route Handlers, middlewares, Edge) et Pages Router.

Installation

npm install @wekivo/next

Côté client

Le provider est RSC-safe — pose-le dans app/layout.tsx (un Server Component), il monte son client en interne sans contaminer ton arbre.

import { KivoProvider } from '@wekivo/next';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="fr">
      <body>
        <KivoProvider apiKey={process.env.NEXT_PUBLIC_KIVO_KEY!}>
          {children}
        </KivoProvider>
      </body>
    </html>
  );
}

Dans un Client Component :

'use client';
import { useKivo } from '@wekivo/next';

export function UpgradeButton({ plan }: { plan: string }) {
  const kivo = useKivo();
  return (
    <button onClick={() => kivo.track('upgrade_clicked', { plan })}>
      Passer en {plan}
    </button>
  );
}

L'API useKivo() est identique à celle de @wekivo/react — voir sa documentation pour les détails (buffer pré-ready, gestion des erreurs).

Côté serveur

@wekivo/next/server expose un helper getKivo() utilisable depuis toute Server Action, Route Handler, middleware ou job background. Aucune dépendance Node — compatible Edge Runtime.

'use server';

import { getKivo } from '@wekivo/next/server';

export async function upgradePlan(plan: string) {
  const session = await getSession();
  const kivo = getKivo({ apiKey: process.env.KIVO_API_KEY! });

  await kivo.event({
    endUserId: session.user.id,
    name: 'plan_upgraded',
    payload: { plan, from: session.user.plan },
  });
}

Edge Runtime

import { getKivo } from '@wekivo/next/server';

export const runtime = 'edge';

export async function POST(req: Request) {
  const body = await req.json();
  const kivo = getKivo({ apiKey: process.env.KIVO_API_KEY! });

  await kivo.identify({
    externalId: body.email,
    email: body.email,
  });

  await kivo.event({
    endUserId: body.email,
    name: 'lead_captured',
    payload: { source: 'landing', utm: body.utm },
  });

  return Response.json({ ok: true });
}

Erreurs

Les réponses non-2xx lèvent une KivoServerError avec le status HTTP :

import { getKivo, KivoServerError } from '@wekivo/next/server';

try {
  await kivo.event({ endUserId, name: 'checkout_completed' });
} catch (err) {
  if (err instanceof KivoServerError && err.status === 429) {
    // throttle — re-essayer plus tard
  } else {
    throw err;
  }
}

Variables d'environnement

NEXT_PUBLIC_KIVO_KEY=kv_xxxxxxxxxxxxxxxxxxxxxxxx
KIVO_API_KEY=kv_xxxxxxxxxxxxxxxxxxxxxxxx

Pour l'instant, la même clé sert côté client et côté serveur (clé tenant unique). Une distinction clé publique / clé secrète arrivera dans une version future — getKivo({ apiKey }) restera le bon nom.

API

<KivoProvider> — re-exporté de @wekivo/react

| Prop | Type | Défaut | Description | | --------- | --------------------------------- | --------- | ----------- | | apiKey | string | — | Clé tenant. Requis. | | host | string | https://api.wekivo.com | Override de l'host API. | | cdnUrl | string | jsDelivr | Override de l'URL CDN du widget. | | endUser | IdentifyPayload | — | Identifie l'utilisateur au mount. | | options | Partial<KivoConfig> | — | Options widget avancées. |

useKivo() — re-exporté de @wekivo/react

Retourne { identify, track, open, close, reset, ready, instance, error }.

getKivo({ apiKey, host?, fetch? })

Retourne { identify, track, event } (ce dernier est un alias de track).

  • identify(user)POST /api/v1/identify — résultat { endUser: { id, externalId } }.
  • event({ endUserId, name, payload?, occurredAt? })POST /api/v1/events — résultat { accepted: number }.

Voir aussi