Packages
AGG ships three npm packages under the@agg-market org. Pick the layer that fits your stack:
| Package | Use when | Peer dependencies |
|---|---|---|
@agg-market/sdk | You’re not using React, or you want full control | None |
@agg-market/hooks | You’re building a React app and want auth + data hooks | @agg-market/sdk, react |
@agg-market/ui | You want pre-built trading UI components | @agg-market/hooks, react, react-dom |
Installation
Install only what you need — each package declares its dependencies on the layers below.- Full stack (recommended)
- Hooks only
- SDK only
@agg-market/sdk
Vanilla TypeScript client. Works in browsers, Node.js, and React Native — no framework dependency.
Setup
Key methods
| Method | Description |
|---|---|
getNonce() | Get a one-time nonce for SIWE sign-in |
buildSiweMessage(params) | Build an EIP-4361 message string |
verifySignIn({ message, signature }) | Verify signature and get a JWT |
signOut() | Clear auth state |
isAuthenticated | Check if user is signed in |
user | Get the current user |
onAuthStateChange(listener) | Subscribe to auth state changes |
Auth persistence
The SDK automatically persists auth sessions tolocalStorage (keyed by appId) and restores them on construction. Partners don’t need to manage tokens.
Headers
The SDK automatically attaches the correct headers on every request:x-app-id— from theappIdyou providedAuthorization: Bearer <jwt>— after sign-inx-admin-key— if you provided anadminKey
@agg-market/hooks
React hooks that wrap @agg-market/sdk. Provides auth flows and data fetching out of the box.
Provider setup
Wrap your app in<AggProvider>:
Hooks
| Hook | Description |
|---|---|
useAggClient() | Access the AggClient instance from context |
useAggAuth({ signMessage, address, chainId }) | Full SIWE sign-in flow — returns { signIn, signOut, isAuthenticated, user, isLoading, error } |
useHello() | Health check — returns { data, error, isLoading } |
SIWE sign-in flow
useAggAuth orchestrates the entire Sign-In with Ethereum flow:
- Fetches a one-time nonce from the API
- Builds an EIP-4361 message
- Prompts the user’s wallet to sign
- Sends the signature to the API for verification
- Stores the returned JWT
@agg-market/ui
Pre-built React components for prediction market UIs. Must be rendered inside an <AggProvider>.
Styling
Import the default theme CSS once at your app entrypoint:.agg-root container:
Tree-shaking
Each component is a separate entry point for optimal bundle size:Available components
| Import path | Component | Description |
|---|---|---|
@agg-market/ui/button | Button | Base button component |
@agg-market/ui/connect-button | ConnectButton | Wallet connection button |
@agg-market/ui/hello-world | HelloWorld | API health check display |
@agg-market/ui/card | Card | Content card |
@agg-market/ui/chart | Chart | Price chart |
@agg-market/ui/skeleton | Skeleton | Loading placeholder |
@agg-market/ui/icon | Icon | Icon set |
@agg-market/ui/badge | Badge | Status badge |
@agg-market/ui/tabs | Tabs | Tab navigation |
@agg-market/ui/select | Select | Dropdown select |
@agg-market/ui/search | Search | Search input |
@agg-market/ui/modal | Modal | Dialog/modal |
@agg-market/ui/event-list | EventList | List of prediction market events |
@agg-market/ui/event-list-item | EventListItem | Single event row |
@agg-market/ui/market-details | MarketDetails | Full market detail view |
@agg-market/ui/place-order | PlaceOrder | Order entry form |
@agg-market/ui/settlement | Settlement | Settlement status |
@agg-market/ui/home-page | HomePage | Full home page layout |
@agg-market/ui/event-market-page | EventMarketPage | Full event/market page |
@agg-market/ui/onboarding-modal | OnboardingModal | User onboarding flow |