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

@opperai/login

v0.4.0

Published

Login with Opper - OAuth SDK for AI inference

Readme

@opperai/login

OAuth SDK for Login with Opper — let your app's users pay for AI inference through their own Opper account.

Ships as a dual ESM / CommonJS package, so it works in both import and require projects (including Next.js server bundles compiled to .cjs).

Install

npm install @opperai/login

Web (Redirect Flow)

import { OpperLogin } from '@opperai/login'

// On your server (keep clientSecret out of the browser bundle):
const opper = new OpperLogin({
  clientId: 'opper_app_...',
  clientSecret: process.env.OPPER_CLIENT_SECRET,
  redirectUri: 'https://myapp.com/callback',
})

// On the callback route:
const { apiKey, user } = await opper.exchangeCode(code)

Note: exchangeCode posts to the token endpoint as application/x-www-form-urlencoded per RFC 6749 §4.1.3. Keep that in mind if you ever reimplement this call without the SDK — posting JSON will fail with 422.

In the browser, start the flow and parse the callback:

const opper = new OpperLogin({
  clientId: 'opper_app_...',
  redirectUri: 'https://myapp.com/callback',
})

opper.authorize()

// On the callback page:
const result = opper.parseCallback()
if (result) {
  // POST result.code to your server, then call exchangeCode there.
}

CLI / Device Flow

import { OpperLogin } from '@opperai/login'

const opper = new OpperLogin({ clientId: 'opper_app_...' })

const device = await opper.startDeviceAuth()

// Prefer verification_uri_complete (RFC 8628 §3.3.1) when the server returns
// it — the user code is pre-filled, so users only click Approve. Always
// show userCode too as a fallback (if the browser opens on another device).
const url = device.verificationUriComplete ?? device.verificationUri
console.log(`Open ${url}`)
console.log(`Code: ${device.userCode}`)

const { apiKey, user } = await opper.pollDeviceToken(device)

For confidential-client CLIs, pass clientSecret in the config and it will be sent automatically.

React

import { LoginWithOpperButton, ManageOpperAccount } from '@opperai/login/react'
import '@opperai/login/styles.css'

<LoginWithOpperButton
  clientId="opper_app_..."
  redirectUri="https://myapp.com/callback"
/>

<ManageOpperAccount />

Both buttons support variant="gradient" (default) and variant="dark":

<LoginWithOpperButton variant="dark" ... />
<ManageOpperAccount variant="dark" />

Portal URL

Returns the URL to the user's Opper Wallet — where they manage their balance, auto-recharge, and connected apps.

const opper = new OpperLogin({ clientId: '...' })
opper.getPortalUrl() // "https://platform.opper.ai/wallet"

Using the API Key

After authentication, use the API key with any OpenAI-compatible client:

const response = await fetch('https://api.opper.ai/v2/call', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'my-function',
    instructions: 'Answer the question.',
    input: 'What is 2+2?',
  }),
})

API

new OpperLogin(config)

| Field | Type | Required | Notes | | -------------- | -------- | ------------------------- | --------------------------------------------------------------------- | | clientId | string | yes | Your OAuth app client ID. | | redirectUri | string | for web redirect / popup | Must match the redirect registered on your OAuth app. | | clientSecret | string | for exchangeCode | Server-side only. Never expose in browser code. | | opperUrl | string | no | Defaults to https://api.opper.ai. | | platformUrl | string | no | Defaults to https://platform.opper.ai. |