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

@crown-dev-studios/simple-auth-react-native

v0.4.0

Published

Client-side auth helpers for React Native and Expo apps using a server-owned auth flow. This package handles secure token persistence, refresh deduplication, and Google auth-code exchange helpers for apps built on the Simple Auth response contracts.

Downloads

413

Readme

@crown-dev-studios/simple-auth-react-native

Client-side auth helpers for React Native and Expo apps using a server-owned auth flow. This package handles secure token persistence, refresh deduplication, and Google auth-code exchange helpers for apps built on the Simple Auth response contracts.

Best For

  • React Native or Expo apps that receive access and refresh tokens from a backend
  • Apps using OTP onboarding or Google OAuth with a server-side exchange step
  • Teams that want a small token manager instead of a full auth framework

Install

npm install @crown-dev-studios/simple-auth-react-native
npm install expo-secure-store

For Google sign-in support:

npm install @crown-dev-studios/google-auth

This package includes native dependencies through expo-secure-store and the optional Google auth module. Expo Go is not supported for Google sign-in.

Token Manager Quick Start

import {
  createSecureStoreTokenStore,
  createSimpleAuthApiClient,
  TokenManager,
} from '@crown-dev-studios/simple-auth-react-native'

const store = createSecureStoreTokenStore('auth_tokens')
const api = createSimpleAuthApiClient({ baseUrl: 'https://api.example.com' })
const tokenManager = new TokenManager(store, api)

Core API

createSecureStoreTokenStore(key)

Creates a token store backed by Expo Secure Store.

const store = createSecureStoreTokenStore('auth_tokens')

Stored tokens look like:

type StoredTokens = {
  accessToken: string
  refreshToken: string
  expiresAt: number
}

createSimpleAuthApiClient({ baseUrl, refreshPath? })

Creates the minimal API client used by TokenManager.

const api = createSimpleAuthApiClient({
  baseUrl: 'https://api.example.com',
  refreshPath: '/auth/refresh',
})

new TokenManager(store, api, options?)

Main helper for token lifecycle management.

Useful methods:

  • getAccessToken()
  • getTokens()
  • setTokens(tokens)
  • setTokensFromAuthTokens(tokens)
  • clearTokens()
  • refreshTokens()
  • fetchWithAuth(input, init?)

Example:

const token = await tokenManager.getAccessToken()

await tokenManager.setTokensFromAuthTokens({
  accessToken: 'access',
  refreshToken: 'refresh',
  expiresIn: 900,
})

TokenManager automatically:

  • Refreshes shortly before expiry
  • Deduplicates concurrent refresh calls
  • Clears invalid refresh tokens
  • Retries one 401 response in fetchWithAuth

Google Auth Helpers

Import Google helpers from the /google entrypoint:

import {
  configureGoogleAuth,
  signInWithGoogle,
  exchangeGoogleAuthCode,
} from '@crown-dev-studios/simple-auth-react-native/google'

await configureGoogleAuth({
  iosClientId: 'your-ios-client-id.apps.googleusercontent.com',
  webClientId: 'your-web-client-id.apps.googleusercontent.com',
})

const { authCode } = await signInWithGoogle()

const result = await exchangeGoogleAuthCode({
  baseUrl: 'https://api.example.com',
  authCode,
})

exchangeGoogleAuthCode expects your server to return the shared Simple Auth OAuth response union:

  • status: 'authenticated'
  • status: 'needs_phone'
  • status: 'needs_linking'

Common Pattern

switch (result.status) {
  case 'authenticated':
    await tokenManager.setTokensFromAuthTokens(result.tokens)
    break
  case 'needs_phone':
    // Continue onboarding with result.sessionToken
    break
  case 'needs_linking':
    // Continue account-linking flow
    break
}

Notes

  • This package assumes your backend owns token minting and refresh.
  • It is storage and transport glue, not a UI kit.
  • If you are not using the Simple Auth response contracts, you can still use the token store and TokenManager with your own refresh client.