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

oidc-provider-solid

v0.1.11

Published

OpenID Connect & OAuth2 authentication using solidjs context api as state management

Readme

oidc-provider-solid

OpenID Connect & OAuth2 authentication provider for SolidJS applications.

Installation

npm install oidc-provider-solid oidc-client-ts

Usage

1. Wrap your app with AuthProvider

import { render } from "solid-js/web";
import { AuthProvider } from "oidc-provider-solid";
import App from "./App";

const config = {
  authority: "https://your-oidc-provider.com",
  client_id: "your-client-id",
  redirect_uri: "http://localhost:3000/callback",
  response_type: "code",
  scope: "openid profile email",
};

// Optional: Custom loading component
const LoadingSpinner = () => (
  <div style={{ display: "flex", justify-content: "center", align-items: "center", height: "100vh" }}>
    <div>Loading...</div>
  </div>
);

render(
  () => (
    <AuthProvider config={config} loadingComponent={<LoadingSpinner />}>
      <App />
    </AuthProvider>
  ),
  document.getElementById("root")!
);

2. Use the useAuth hook in your components

import { useAuth } from "oidc-provider-solid";

function MyComponent() {
  const { user, isAuthenticated, isLoading, login, logout } = useAuth();

  if (isLoading()) {
    return <div>Loading...</div>;
  }

  return (
    <div>
      {isAuthenticated() ? (
        <>
          <h1>Welcome, {user()?.profile.name}!</h1>
          <p>Email: {user()?.profile.email}</p>
          <button onClick={logout}>Logout</button>
        </>
      ) : (
        <button onClick={login}>Login with OIDC</button>
      )}
    </div>
  );
}

API Reference

AuthProvider

The main provider component that manages authentication state and provides loading state management.

Props:

  • config: UserManagerSettings - OIDC client configuration
    • authority: Your OIDC provider URL
    • client_id: Your application's client ID
    • redirect_uri: Callback URL after authentication
    • response_type: OAuth2 response type (typically "code")
    • scope: Requested scopes (e.g., "openid profile email")
  • children: JSX.Element - Child components to be wrapped with auth context
  • loadingComponent?: JSX.Element - Optional component to show during authentication loading state (prevents flickering of previous content)

useAuth Hook

Returns the authentication context with the following properties:

  • user: () => User | null - Current authenticated user
  • isAuthenticated: () => boolean - Whether the user is authenticated
  • isLoading: () => boolean - Loading state during authentication
  • login: () => Promise<void> - Initiate login flow
  • logout: () => Promise<void> - Logout the user

AuthService

Low-level service for direct OIDC operations:

import { AuthService } from "oidc-provider-solid";

const authService = new AuthService(config);

// Check if current URL is a callback
if (authService.isCallbackUrl()) {
  const user = await authService.handleCallback();
}

// Get current user
const user = await authService.getUser();

// Check authentication
const isAuth = await authService.isAuthenticated();

// Login
await authService.redirectToLogin();

// Logout
await authService.logout();

Configuration Examples

Basic Configuration

const config = {
  authority: "https://accounts.google.com",
  client_id: "your-google-client-id",
  redirect_uri: "http://localhost:3000/callback",
  response_type: "code",
  scope: "openid profile email",
};

Advanced Configuration

const config = {
  authority: "https://your-oidc-provider.com",
  client_id: "your-client-id",
  redirect_uri: "http://localhost:3000/callback",
  post_logout_redirect_uri: "http://localhost:3000/",
  response_type: "code",
  scope: "openid profile email offline_access",
  automaticSilentRenew: true,
  silentRequestTimeout: 10000,
  loadUserInfo: true,
};

License

MIT License - see LICENSE file for details.