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

sp-next-auth-refresh

v0.1.0

Published

Client-side helpers for Suzag apps using NextAuth

Readme

sp-next-auth-refresh

클라이언트 사이드에서 NextAuth 세션을 자동 갱신하기 위한 헬퍼입니다. Suzag 계열 Next.js 애플리케이션에서 access token 만료 전에 미리 refresh를 호출하여 /no-access로 튕기는 문제를 방지합니다.

설치

pnpm add sp-next-auth-refresh

Next.js 프로젝트에서는 next.config.js(또는 next.config.ts)에 transpilePackages 옵션을 추가하는 것을 권장합니다.

const nextConfig = {
  transpilePackages: ['sp-next-auth-refresh'],
};
module.exports = nextConfig;

사용법

SessionProvider 하위에 AutoRefreshSessionProvider를 배치하면 됩니다.

import { SessionProvider } from 'next-auth/react';
import { AutoRefreshSessionProvider } from 'sp-next-auth-refresh';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <SessionProvider>
      <AutoRefreshSessionProvider>
        {children}
      </AutoRefreshSessionProvider>
    </SessionProvider>
  );
}

기본 설정은 access token 만료 2분 전에 자동으로 refresh를 시도하며, 실패 시 /login으로 리다이렉트합니다.

옵션

<AutoRefreshSessionProvider
  refreshBufferMs={120_000}
  refreshEndpoint="/api/auth/session?update=true"
  redirectOnError="/login"
  onRefreshSuccess={() => console.log('refreshed')}
  onRefreshError={(error) => console.error(error)}
  refreshOnFocus
  refreshOnVisibility
>
  {children}
</AutoRefreshSessionProvider>
  • refreshBufferMs: 만료 몇 ms 전에 refresh 할지 설정합니다.
  • refreshEndpoint: refresh 전에 호출할 엔드포인트입니다. 기본은 NextAuth 세션 엔드포인트입니다.
  • redirectOnError: refresh 실패 시 signIn으로 이동할 URL입니다.
  • onRefreshSuccess / onRefreshError: 성공/실패 콜백입니다.
  • refreshOnFocus / refreshOnVisibility: 포커스, visibility 변경 시 추가로 갱신을 시도합니다.

유틸리티

JWT 만료 정보를 확인해야 하는 경우 아래 함수를 사용할 수 있습니다.

import { getTokenExpiry, shouldRefreshToken } from 'sp-next-auth-refresh';

const expiresAt = getTokenExpiry(session.accessToken);
const needsRefresh = shouldRefreshToken(session.accessToken, 120_000);

라이선스

MIT