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

@yan06/openai-oauth-react

v2.0.2

Published

React hook and button for OpenAI OAuth sessions.

Readme

@yan06/openai-oauth-react

Docs | GitHub | npm

Let your users sign in with their ChatGPT accounts.

npm i @yan06/openai-oauth-react

Quickstart:

"use client";

import { SignInWithChatGPT } from "@yan06/openai-oauth-react";

export default function Page() {
	return <SignInWithChatGPT />;
}

Package Notes

SignInWithChatGPT renders the OpenAI-style sign-in button. After sign-in, it becomes a disconnect button.

The prebuilt button includes a small "Powered by OpenAI OAuth" link by default. Pass hideAttribution to render only the button with no attribution link or reserved space.

Hosted web apps need the open-source Sign in with ChatGPT extension for Chrome or Firefox to complete the OAuth handoff securely. SignInWithChatGPT detects the current browser, shows the correct install screen when needed, and automatically continues once installation is detected. Developers do not need to configure the extension separately.

Browser model calls must go through your own app route because ChatGPT does not allow direct browser CORS requests. Send the signed-in session to that route with openaiAuthHeaders():

"use client";

import { openaiAuthHeaders, SignInWithChatGPT } from "@yan06/openai-oauth-react";

async function ask() {
	const response = await fetch("/api/chat", {
		method: "POST",
		headers: await openaiAuthHeaders({
			headers: { "content-type": "application/json" },
		}),
		body: JSON.stringify({ prompt: "Hello!" }),
	});

	return response.text();
}

openaiAuthHeaders() returns a plain object, so it can be passed directly to fetch, AI SDK hooks, and other code that spreads header objects.

Read the request-bound credentials on your server:

import { createOpenAIOAuth } from "@yan06/openai-oauth-ai-sdk";
import { openaiCredentials } from "@yan06/openai-oauth-react/server";
import { generateText } from "ai";

export async function POST(request: Request) {
	const { prompt } = await request.json();
	const openai = createOpenAIOAuth(openaiCredentials(request));

	const result = await generateText({
		model: openai("gpt-5.4-mini"),
		prompt,
	});

	return Response.json({ text: result.text });
}

Useful props:

<SignInWithChatGPT
	onSuccess={(session) => console.log(session.accountId)}
	onError={(error) => console.error(error.message)}
	onStateChange={(state) => console.log(state.status)}
	hideAttribution
/>

For custom UI, use the hook. Custom interfaces are responsible for presenting the extension installation link when needed.

import { useSignInWithChatGPT } from "@yan06/openai-oauth-react";

function CustomLogin() {
	const login = useSignInWithChatGPT();

	if (login.status === "signed-in") {
		return <button onClick={login.logout}>Disconnect</button>;
	}

	if (login.status === "needs-extension") {
		return (
			<div>
				<a href={login.installUrl} rel="noreferrer" target="_blank">
					Install Sign in with ChatGPT
				</a>
				<button onClick={login.login}>Try again</button>
				<button onClick={login.reset}>Cancel</button>
			</div>
		);
	}

	return (
		<button onClick={login.login}>Sign in with ChatGPT</button>
	);
}

The hook returns:

type UseSignInWithChatGPTReturn = SignInWithChatGPTState & {
	isSignedIn: boolean;
	login(): Promise<void>;
	logout(): Promise<void>;
	refresh(): Promise<OpenAIOAuthSession | null>;
	reset(): Promise<void>;
};

State statuses:

"checking" | "signed-out" | "starting" | "needs-extension" | "redirecting" | "signed-in" | "error"

The default browser session store persists encrypted sessions in IndexedDB. Apps can provide their own store:

import { createSessionStore } from "@yan06/openai-oauth-react";

const sessionStore = createSessionStore();

type SessionStore = {
	get(): Promise<OpenAIOAuthSession | null>;
	set(session: OpenAIOAuthSession): Promise<void>;
	clear(): Promise<void>;
};

Exports:

  • SignInWithChatGPT
  • useSignInWithChatGPT
  • openaiAuthHeaders
  • getSession
  • createSessionStore
  • openaiCredentials from @yan06/openai-oauth-react/server

More

Learn more in the openai-oauth README.