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

swissoid-front

v0.1.4

Published

SwissOID frontend helpers for relying-party applications

Readme

swissoid-front

SwissOID frontend helpers for relying-party applications. The package bundles the wiring we introduced in clockize-react so any React app can plug into the SwissOID session managed by a backend that exposes the swissoid-back implementation.

Features

  • SwissOIDAuthProvider – context provider that keeps track of the SwissOID session, polls /auth/status, and exposes helpers to login, logout, refresh the session, and re-check status.
  • useSwissOIDAuth() – hook that returns the current authentication state and helpers.
  • AuthGuard – simple component that protects a subtree, optionally auto-redirecting to the backend login endpoint when the session has expired.
  • AuthDebugPanel – drop-in diagnostics panel useful during integration to inspect cookies, raw payloads, and trigger session actions.
  • createSwissOIDBackendClient() – utility that mimics the utils/oidc.ts helpers from clockize-react (initiateLogin, checkAuthStatus, logout) but works with any backend URL and endpoint configuration.

Quick start

import React from 'react';
import { SwissOIDAuthProvider, AuthGuard } from 'swissoid-front';

const App = () => (
  <SwissOIDAuthProvider
    config={{
      backendUrl: import.meta.env.VITE_BACKEND_URL,
      pollIntervalMs: 30_000,
    }}
  >
    <AuthGuard loadingFallback={<span>Loading session…</span>}>
      {/* protected routes */}
    </AuthGuard>
  </SwissOIDAuthProvider>
);

Inside your components you can access the session data:

import { useSwissOIDAuth } from 'swissoid-front';

const UserMenu = () => {
  const { user, logout } = useSwissOIDAuth();

  return (
    <button onClick={() => logout({ redirectTo: '/' })}>
      Sign out {user && (user as any).email}
    </button>
  );
};

To reproduce the clockize-react helpers:

import { createSwissOIDBackendClient } from 'swissoid-front';

const backend = createSwissOIDBackendClient({ backendUrl: import.meta.env.VITE_BACKEND_URL });

export const initiateLogin = backend.initiateLogin;
export const checkAuthStatus = () => backend.checkAuthStatus().then((res) => res.json());
export const logout = () => backend.logout({ redirectTo: '/' });

Configuration options

The provider accepts the following configuration:

| Option | Description | Default | | ------ | ----------- | ------- | | backendUrl | Base URL of the relying-party backend that mounted swissoid-back routes. | Required | | endpoints | Override paths for status, login, logout, refresh. | /auth/status, /login, /auth/logout, /auth/refresh | | pollIntervalMs | Interval for background /auth/status checks. | 30000 (30s) | | fetchImplementation | Custom fetch (useful in SSR/tests). | globalThis.fetch | | transformUser | Map the response payload to the user object stored in context. | identity | | loginRedirectParam | Query parameter name for continue URLs. | continue | | logoutRedirectTo | URL or callback invoked after logout. | none | | initialUser | Seed user (useful for SSR). | null | | defaultHeaders | Headers sent with backend requests. | none |

Building

npm install
npm run build

Installing dependencies can take a moment – if it times out, re-run the command locally.

The build emits dual CJS/ESM bundles with TypeScript declarations under dist/.