Drift Common is a production-ready monorepo that powers Drift Protocol applications with shared utilities, React components, and design system elements.
What is Drift Common?
Drift Common is a TypeScript monorepo that provides essential building blocks for developing applications in the Drift Protocol ecosystem. It consolidates common functionality, React components, and icon assets into three specialized packages that work seamlessly together. The monorepo consists of three packages:@drift-labs/common
Core utilities for Drift Protocol integration, including client libraries, math utilities, and common types
@drift-labs/react
React hooks, components, and providers for building Drift-powered applications
@drift-labs/icons
React icon components generated from Figma designs
Quick Links
Installation
Get started by installing the packages you need
Quick Start
Build your first Drift application in minutes
Key Features
Production-Ready Utilities
Comprehensive set of utilities for working with Drift Protocol, including math operations, token handling, WebSocket clients, and RPC management.React Integration
Purpose-built React hooks and components that simplify wallet connection, Drift client management, and state synchronization.Type Safety
Full TypeScript support with comprehensive type definitions for all packages, ensuring type-safe development.WebSocket Clients
Battle-tested WebSocket clients for real-time data feeds including DLOB (Decentralized Limit Order Book), market data, and candle data.Solana Wallet Support
Seamless integration with Solana wallet adapters, including custom autoconnect logic and mobile wallet support.State Management
Built-in state management using Zustand and Immer for efficient React state updates.UI Components
Ready-to-use UI components including charts, loaders, selects, tables, tags, and text components.Icon System
Extensive icon library with React components automatically generated from Figma designs.Package Overview
@drift-labs/common
The core package providing fundamental utilities and client libraries for Drift Protocol integration. Key Exports:EnvironmentConstants- RPC endpoints and server URLs for different environmentsInitialize- SDK configuration and market initialization- Client libraries for DLOB, market data, candles, and Swift
- Math utilities for orderbook calculations
- Token utilities for SPL token operations
- WebSocket multiplexing and connection management
- Circular buffers and data structures
@drift-labs/sdk^2.158.0-beta.0@solana/web3.js1.98.0rxjs7.8.2immer10.0.3
@drift-labs/react
React-specific components, hooks, and providers for building Drift applications. Key Exports:DriftProvider- Main provider for Drift functionalityDriftWalletProvider- Wallet connection and state managementuseWalletContext- Access wallet stateuseCommonDriftActions- Common Drift actionsuseDriftClientIsReady- Check Drift client readinessuseSolBalance- Monitor SOL balance- Chart components and hooks
- UI components (Loaders, Select, Tables, Tags, Text)
react19.0.3@drift-labs/sdk^2.158.0-beta.0@solana/wallet-adapter-react0.15.35zustand4.3.8immer10.0.2
@drift-labs/icons
React icon components with automatic Figma-to-React generation. Key Features:- Automatically generated from Figma designs
- TypeScript support
- Tree-shakeable exports
- Consistent sizing and styling
Architecture
Drift Common follows a monorepo structure with clear separation of concerns:Engine Requirements
- Node.js: ^24.x.x (for @drift-labs/common)
- React: 19.0.3 (for @drift-labs/react)
Next Steps
Install Packages
Install the packages you need for your project
Quick Start Guide
Follow our quick start guide to build your first app