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

@growsober/sdk

v1.0.6

Published

Shared TypeScript SDK for GrowSober API - TanStack Query hooks, API client, and utilities

Readme

@growsober/sdk

TypeScript SDK for the GrowSober API with TanStack Query hooks.

Installation

npm install @growsober/sdk @tanstack/react-query axios

Quick Start

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { configureSDK, useCurrentUser, useHubs, useEvents } from '@growsober/sdk';

// Configure SDK
configureSDK({
  baseURL: 'https://api.growsober.app',
  getAccessToken: () => localStorage.getItem('accessToken'),
  refreshAccessToken: async () => {
    // Your token refresh logic
    const response = await fetch('/refresh');
    const { accessToken } = await response.json();
    localStorage.setItem('accessToken', accessToken);
    return accessToken;
  },
  onUnauthorized: () => {
    window.location.href = '/login';
  },
});

// Create query client
const queryClient = new QueryClient();

// Use in app
function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <MyComponent />
    </QueryClientProvider>
  );
}

function MyComponent() {
  const { data: user, isLoading } = useCurrentUser();
  const { data: hubs } = useHubs();

  if (isLoading) return <Loading />;

  return <div>Welcome, {user?.name}</div>;
}

Available Hooks

Auth Hooks

// Queries
useMe()                    // Get current auth user

// Mutations
useRegister()              // Register new user
useLogin()                 // Login with credentials
useFirebaseAuth()          // Login with Firebase token
useRefreshAuthToken()      // Refresh access token

User Hooks

// Queries
useCurrentUser()           // Get current user profile
useUser(id)                // Get user by ID
usePublicProfile(id)       // Get public profile
useMyBookmarks()           // Get bookmarked content
useMyRedeemedOffers()      // Get redeemed offers

// Mutations
useUpdateCurrentUser()     // Update profile
useCompleteOnboarding()    // Complete onboarding

Hub Hooks

// Queries
useHubs(filters?)          // List hubs with filters
useHub(id)                 // Get hub by ID
useHubBySlug(slug)         // Get hub by slug
useMyHubs()                // Get joined hubs
useHubMembers(id)          // Get hub members
useHubMembership(id)       // Check membership status

// Mutations
useCreateHub()             // Create new hub
useUpdateHub()             // Update hub
useDeleteHub()             // Delete hub
useJoinHub()               // Join hub
useLeaveHub()              // Leave hub
useApproveMember()         // Approve member
useUpdateMemberRole()      // Update member role
useRemoveMember()          // Remove member

Event Hooks

// Queries
useEvents(filters?)        // List events
useEvent(id)               // Get event by ID
useEventBySlug(slug)       // Get event by slug
useUpcomingEvents()        // Get upcoming events
useFeaturedEvents()        // Get featured events
useEventBookings(id)       // Get event attendees

// Mutations
useCreateEvent()           // Create event
useUpdateEvent()           // Update event
useDeleteEvent()           // Delete event
useCancelEvent()           // Cancel event
usePublishEvent()          // Publish event

Booking Hooks

// Queries
useBooking(id)             // Get booking
useMyBookings()            // Get my bookings
useBookingQrCode(id)       // Get QR code

// Mutations
useCreateBooking()         // Book event (RSVP)
useCancelBooking()         // Cancel booking
useCheckInBooking()        // Check in at event

Library Hooks

// Queries
useLibraryContent(filters?) // List content
useFeaturedContent()        // Featured content
useLibraryCategories()      // Content categories
useLibraryItem(id)          // Get content item
useMyProgress()             // Get reading progress

// Mutations
useMarkViewed()             // Mark as viewed
useMarkCompleted()          // Mark as completed
useToggleLike()             // Like/unlike content
useAddBookmark()            // Add bookmark
useRemoveBookmark()         // Remove bookmark

Business & Offer Hooks

// Queries
useBusinesses(filters?)     // List businesses
useBusiness(id)             // Get business
useFeaturedBusinesses()     // Featured businesses
useNearbyBusinesses(lat, lng) // Nearby businesses
useBusinessOffers(id)       // Get business offers
useOffers(filters?)         // List offers
useOffer(id)                // Get offer
useCanRedeemOffer(id)       // Check redemption

// Mutations
useRedeemOffer()            // Redeem offer

Subscription Hooks

// Queries
useSubscriptionPlans()      // Available plans
useMySubscription()         // Current subscription

// Mutations
useCreateCheckout()         // Create Stripe checkout
useCustomerPortal()         // Get portal URL
useCancelSubscription()     // Cancel subscription
useResumeSubscription()     // Resume subscription

Notification Hooks

// Queries
useNotifications()          // List notifications
useUnreadNotificationCount() // Unread count
useNotification(id)         // Get notification

// Mutations
useMarkNotificationRead()   // Mark as read
useMarkAllNotificationsRead() // Mark all read
useDeleteNotification()     // Delete notification

Support Hooks

// Queries
useCheckIns()              // List check-ins
useTodayCheckIn()          // Today's check-in
useCheckInStreak()         // Current streak
useMoodLogs()              // List mood logs
useWins()                  // List wins
useWinsByCategory()        // Wins by category
useHabits()                // List habits
useReflections()           // List reflections

// Mutations
useCreateCheckIn()         // Create check-in
useCreateMoodLog()         // Log mood
useCreateWin()             // Log win
useCreateHabit()           // Create habit
useUpdateHabit()           // Update habit
useDeleteHabit()           // Delete habit
useCompleteHabit()         // Complete habit
useCreateReflection()      // Create reflection

Query Key Factories

Each module exports query key factories for cache management:

import { userKeys, hubKeys, eventKeys } from '@growsober/sdk';

// Invalidate all user queries
queryClient.invalidateQueries({ queryKey: userKeys.all });

// Invalidate specific hub
queryClient.invalidateQueries({ queryKey: hubKeys.detail('hub-id') });

// Prefetch events
queryClient.prefetchQuery({
  queryKey: eventKeys.list(),
  queryFn: () => fetchEvents(),
});

Types

All types are re-exported from @growsober/types:

import type {
  UserResponse,
  HubResponse,
  EventResponse,
  BookingResponse,
  // ... etc
} from '@growsober/sdk';

Error Handling

const { mutate: createEvent, error } = useCreateEvent({
  onError: (error) => {
    console.error('Failed to create event:', error.message);
  },
});

Development

# Type check
npm run type-check

# Build
npm run build

# Watch mode
npm run build:watch

License

UNLICENSED - Proprietary