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

auth-platform-sdk

v3.2.1

Published

Official SDK for Auth Platform — OAuth 2.0 + PKCE authentication for Next.js apps

Readme

Auth Platform SDK

Official TypeScript SDK for Auth Platform — OAuth 2.0 + PKCE authentication for Next.js apps.

Install

npm install auth-platform-sdk

Setup (4 steps)

1. Environment Variables

Create .env.local in your Next.js project root:

NEXT_PUBLIC_AUTH_SERVER=https://auth.example.com
NEXT_PUBLIC_CLIENT_ID=your-client-id
NEXT_PUBLIC_REDIRECT_URI=http://localhost:3000/callback

# Server-side only — NEVER prefix with NEXT_PUBLIC_
AUTH_CLIENT_SECRET=your-client-secret

2. Auth Proxy Route

Create app/api/auth/[...path]/route.ts:

import { createAuthProxy } from 'auth-platform-sdk/server';
import type { NextRequest } from 'next/server';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

const proxy = createAuthProxy();
type Ctx = { params: Promise<{ path?: string[] }> };
async function handler(req: NextRequest, ctx: Ctx): Promise<Response> {
  return proxy(req, ctx);
}

export const GET  = handler;
export const POST = handler;

3. Wrap App with AuthProvider

In your layout.tsx:

import { AuthProvider } from 'auth-platform-sdk/client';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html><body>
      <AuthProvider>{children}</AuthProvider>
    </body></html>
  );
}

4. Use in Components

'use client';
import { useAuth } from 'auth-platform-sdk/client';

export default function Page() {
  const { user, login, logout, isAuthenticated, loading } = useAuth();

  if (loading) return <p>Loading...</p>;
  if (!isAuthenticated) return <button onClick={() => login()}>Sign In</button>;

  return (
    <div>
      <p>Hello {user?.email}!</p>
      <button onClick={logout}>Sign Out</button>
    </div>
  );
}

Security Architecture

Browser (client)              Server (proxy)              Auth Server
┌─────────────────┐          ┌───────────────────────┐    ┌──────────────┐
│ PKCE verifier    │  ────►  │ + client_secret        │ ──►│ Validates    │
│ State (CSRF)     │          │ + HttpOnly cookies     │    │ both PKCE &  │
│ Login redirect   │          │ + Token scrubbing      │    │ client_secret│
│ No secrets       │          │ + Cookie cleanup       │    │              │
│ No tokens in JS  │  ◄────  │ { authenticated: true } │ ◄──│ Issues tokens│
└─────────────────┘          └───────────────────────┘    └──────────────┘

API Reference

Client Exports (auth-platform-sdk/client)

| Export | Type | Description | |--------|------|-------------| | AuthClient | Class | Core OAuth client | | AuthProvider | Component | React context provider | | useAuth() | Hook | Access auth state | | AuthUser | Type | User object shape | | AuthContextValue | Type | useAuth() return type |

Server Exports (auth-platform-sdk/server)

| Export | Type | Description | |--------|------|-------------| | createAuthProxy() | Function | Route handler factory | | AuthProxyOptions | Type | Factory config | | AuthProxyHandler | Type | Handler function type |

License

MIT