Skip to Content
StacksPackagesPackages

Packages

Stacknet provides a set of npm packages for integrating authentication, key management, and content storage into your Stack’s frontend.

@stacknet/userutils

npm 

Authentication, session management, and billing for Stacknet apps. Provides Google, Telegram, X, Discord and Web3 wallet login (Solana, Ethereum), cross-domain SSO via auth bridge, and billing/subscription hooks.

Key exports

ExportDescription
UserUtilsProviderReact context provider — wrap your app with this
ConnectWidgetDrop-in wallet connect UI (Phantom, MetaMask)
useSessionRead public session state (userId, address, expiresAt)
useWeb3WalletWallet connection state and provider detection
useStackAuthFull auth flow (challenge, sign, verify)
useAuthBridgeCross-domain SSO via postMessage
usePlansList available billing plans
useSubscriptionCurrent subscription state
useUsageToken usage summary
useBillingHistoryPast billing records
usePrepaidCheckoutCredit purchase flow

Quick start

import { UserUtilsProvider, ConnectWidget } from '@stacknet/userutils/components' import { useSession } from '@stacknet/userutils/hooks' function App() { return ( <UserUtilsProvider config={{ apiBaseUrl: 'https://stacknet.magma-rpc.com', stackId: 'your_stack_id', theme: 'dark', }}> <MyApp /> </UserUtilsProvider> ) } function MyApp() { const { session, isAuthenticated } = useSession() if (!isAuthenticated) return <ConnectWidget config={config} /> return <p>Connected: {session.address}</p> }

@stacknet/keyutils

npm 

Node Key management — purchase, transfer, and marketplace operations. Handles Solana Pay transactions, device fingerprinting, and peer-to-peer key transfers.

Key exports

ExportDescription
TransferPanelUI for peer-to-peer key transfers (gifting)
useTransferKeyHook to initiate key transfers
SolanaPayButtonPayment button with dual-transfer pattern

Features

  • Atomic transfers — peer-to-peer key gifting
  • Solana Pay — solana based transfers
  • Device fingerprinting — anti-fraud velocity checks
  • Marketplace — buy/sell keys on the secondary market

Quick start

import { TransferPanel } from '@stacknet/keyutils' function KeyManager({ keyId }: { keyId: string }) { return ( <TransferPanel keyId={keyId} onSuccess={(txId) => console.log('Transferred:', txId)} /> ) }

@stacknet/rackutils

npm 

React hooks and components for Stacknet Racks — the IPFS-backed version control system for skills, tensors, and AI artifacts.

Key exports

Hooks (13):

HookDescription
useRackClientCore API client (17 methods)
useRackSessionAPI key auth, login/logout, budget tracking
useReposList repos
usePaginatedReposCursor-based infinite scroll
useRepoTreeFile tree navigation
useRepoPushPush files to a repo
useRackRegisterRegister skills and tensors
useSkillStatsSkill metadata and usage counts
useTensorStatsTensor metadata and size
useNetworkStatsNetwork-wide statistics
useTrendingTrending repos
useStarStar/unstar repos

Components (3):

ComponentDescription
RackBrowserFull repo browser with file tree, skill upload
MarkdownLightweight markdown renderer
StarButtonStar/unstar toggle with count

Quick start

import { useRackSession, useRepos } from '@stacknet/rackutils' function RackExplorer() { const { session, login } = useRackSession() const { repos, loading } = useRepos() if (!session) return <button onClick={() => login('gk_your_key')}>Connect</button> return ( <ul> {repos.map(repo => ( <li key={repo.id}>{repo.name}</li> ))} </ul> ) }

Cost estimation

import { estimateCost } from '@stacknet/rackutils' // Skills: (100 + ceil(bytes/4)) × 1000 tokens estimateCost('skill', 4096) // → 1,124,000 tokens // Tensors: (100 + ceil(MB)) × 1000 tokens estimateCost('tensor', 50_000_000) // → 148,000 tokens
Last updated on