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

@archlast/sdk-next

v0.1.1

Published

Archlast SDK for Next.js with SSR support

Readme

@archlast/sdk-next

Archlast SDK for Next.js with SSR (Server-Side Rendering) support.

Installation

npm install @archlast/sdk-next

Features

  • SSR Session Reading: Get session data in server components and route handlers
  • Middleware Helpers: Cookie-based authentication checks for protected routes
  • Better-Auth Wrapped: No need to install better-auth directly
  • App Router Support: Built for Next.js 15+ App Router
  • Type-Safe: Full TypeScript support

Usage

Server Components

import { getServerSession } from "@archlast/sdk-next";

export default async function Profile() {
  const session = await getServerSession();

  if (!session) {
    return <div>Please sign in</div>;
  }

  return <div>Welcome, {session.user.name}!</div>;
}

Route Handlers

import { getServerSession } from "@archlast/sdk-next";
import { NextResponse } from "next/server";

export async function GET() {
  const session = await getServerSession();

  if (!session) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  return NextResponse.json({ user: session.user });
}

Middleware

// middleware.ts
import { requireAuth } from "@archlast/sdk-next";
import { NextRequest } from "next/server";

export function middleware(request: NextRequest) {
  // Protect all routes except /login and /api/auth
  if (
    !request.nextUrl.pathname.startsWith("/login") &&
    !request.nextUrl.pathname.startsWith("/api/auth")
  ) {
    const authResult = requireAuth(request, "/login");
    if (authResult) return authResult;
  }

  return NextResponse.next();
}

export const config = {
  matcher: ["/((?!api/auth|_next/static|_next/image|favicon.ico).*)"],
};

Client Components

"use client";

import { useAuth } from "@archlast/sdk-next/react";

export default function Profile() {
  const { session, isLoading } = useAuth();

  if (isLoading) return <div>Loading...</div>;
  if (!session) return <div>Please sign in</div>;

  return <div>Welcome, {session.user.name}!</div>;
}

Using Better-Auth Directly

"use client";

import { authClient } from "@archlast/sdk-next/auth";

export default function LoginForm() {
  const handleSubmit = async () => {
    await authClient.signIn.email({
      email: "[email protected]",
      password: "password",
    });
  };

  return <button onClick={handleSubmit}>Sign In</button>;
}

Environment Variables

# Optional: Set Better-Auth server URL
# Defaults to http://localhost:4000/api/auth
NEXT_PUBLIC_BETTER_AUTH_URL=http://localhost:4000

# Or use Archlast URL
NEXT_PUBLIC_ARCHLAST_HTTP_URL=http://localhost:4000

API

Server Functions

  • getServerSession() - Get session in server components/route handlers
  • getCookieHeader() - Get cookies as string for forwarding
  • getSessionHeaders() - Get headers for authenticated requests

Middleware

  • createMiddlewareClient(request) - Create middleware client
  • requireAuth(request, redirectTo?) - Helper to protect routes

Auth

  • authClient - Better-Auth client for sign in/out
  • useSession() - Hook for session state
  • createAuthClient(options) - Create custom auth client

Examples

Protected Server Component

import { getServerSession } from "@archlast/sdk-next";
import { redirect } from "next/navigation";

export default async function Dashboard() {
  const session = await getServerSession();

  if (!session) {
    redirect("/login");
  }

  return (
    <div>
      <h1>Dashboard</h1>
      <p>Welcome, {session.user.name}!</p>
    </div>
  );
}

API Route with Session

import { getServerSession } from "@archlast/sdk-next";
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const session = await getServerSession();

  if (!session?.user) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  // Process request...
  return NextResponse.json({ success: true });
}

License

MIT