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

@skein-js/nextjs

v0.9.0

Published

Next.js adapter for skein-js — serve the Agent Protocol from App Router or Pages Router API routes.

Readme

@skein-js/nextjs

Next.js adapter for skein-js — serve the Agent Protocol from Next.js API routes.

Part of skein-js — a TypeScript Agent Protocol server for LangGraph.js, and a drop-in replacement for the LangGraph CLI.

A thin transport shim over the framework-agnostic @skein-js/agent-protocol handler table — it adds no protocol logic. Mount the protocol same-origin inside an existing Next.js app (no separate server, no CORS), ideal for small/medium graphs shipped alongside your frontend. Supports both the App Router and the Pages Router.

Install

npm i @skein-js/nextjs @langchain/langgraph

App Router (recommended)

A catch-all route re-exports the per-method handlers:

// app/api/[...path]/route.ts
import { createSkeinRouteHandlers } from "@skein-js/nextjs";

export const runtime = "nodejs"; // the background run worker needs a long-lived Node process
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = createSkeinRouteHandlers({
  config: "./langgraph.json",
});

Point a browser client at the same origin — no CORS needed:

import { useStream } from "@langchain/langgraph-sdk/react";
const thread = useStream({ apiUrl: "/api", assistantId: "agent" });

Pages Router

// pages/api/[...path].ts
import { createSkeinPagesHandler } from "@skein-js/nextjs";

// Let Next know this route settles the response itself (needed for SSE streaming).
export const config = { api: { bodyParser: true, externalResolver: true } };
export default createSkeinPagesHandler({ config: "./langgraph.json" });

Both entry points accept the shared { config } | { deps } seam, an optional cors (off by default), and a basePath (defaults to /api, matching the mount above).

Graphs as plain endpoints (non-chat)

For workloads that aren't chat — a classifier, an extractor, a workflow another service calls — there is a smaller surface: every graph mounted as POST <basePath>/:graph_id, where the request body is the graph input and the response is the final state. No threads, assistants, or runs.

// app/api/invoke/[graph_id]/route.ts
import { createSkeinInvokeRouteHandlers } from "@skein-js/nextjs";

export const runtime = "nodejs";
export const { POST } = createSkeinInvokeRouteHandlers({ deps, basePath: "/api/invoke" });

Send Accept: text/event-stream to stream the steps instead. See docs/serving-a-single-graph.md.

Deployment caveat

The background run worker and the in-memory driver need a long-lived Node process — fine on next start with runtime = "nodejs". For serverless/edge deploys, back skein with the Redis queue + Postgres store (pass { deps } from @skein-js/runtime's buildRuntime) so state and runs don't depend on one process.

API

  • createSkeinRouteHandlers(options): SkeinRouteHandlers — App Router (recommended); returns { GET, POST, PUT, PATCH, DELETE, OPTIONS } to re-export from app/<base>/[...path]/route.ts.
  • createSkeinPagesHandler(options): SkeinPagesHandler — Pages Router; the default export for pages/api/[...path].ts.
  • createSkeinInvokeRouteHandlers(options): SkeinInvokeRouteHandlers — the simplified serving surface (POST <basePath>/:graph_id, body-in / final-state-out); returns { POST, OPTIONS } for app/api/invoke/[graph_id]/route.ts. basePath defaults to /api/invoke; adds streamMode.
  • Both accept SkeinRouteHandlerOptions / SkeinPagesHandlerOptions: the shared { config, importModule? } | { deps } seam plus an optional cors (off by default) and a basePath (defaults to /api, matching the mount). deps comes from @skein-js/runtime's buildRuntime for production Postgres/Redis.
  • getSkeinRuntime(options): Promise<ResolvedProtocolRuntime> — the memoized runtime accessor shared by both routers (survives dev module reloads); its .runtime is the ProtocolRuntime (assistants, handlers, worker).
  • SkeinRuntimeOptions — the shared runtime-resolution option shape, re-exported for typing your own wrappers.
  • Low-level serializers: toWebResponse / webErrorResponse (Web Response), plus sendNodeResponse / sendNodeError (re-exported from @skein-js/server-kit).

Learn more

License

Apache-2.0