Overview
The YouVersion Platform React SDK is designed with a three-layer architecture that promotes separation of concerns, type safety, and maintainability. This architecture ensures that each layer has a clear responsibility and can be used independently or together.The Three Layers
Layer 1: Core (@youversion/platform-core)
Pure TypeScript API clients with zero dependencies on React or browser-specific APIs.
The core layer provides framework-agnostic API clients for interacting with YouVersion services. It’s built with:
- Zero React dependencies - Can be used in Node.js, Deno, or any JavaScript environment
- Schema-first design - All types defined using Zod for runtime validation
- Native fetch API - No external HTTP dependencies
- Storage abstraction - Pluggable storage strategies for auth tokens
ApiClient- Main HTTP client with auth handling and timeout supportBibleClient- Fetch Bibles, chapters, verses, versionsLanguagesClient- Get available languagesHighlightsClient- Manage user highlightsSignInWithYouVersionPKCE()- OAuth 2.0 PKCE authentication flow- Storage strategies:
SessionStorage,MemoryStorage
The core package is completely framework-agnostic. You can use it in any JavaScript environment, not just React applications.
Layer 2: Hooks (@youversion/platform-react-hooks)
React integration layer that wraps core clients with React hooks and context providers.
The hooks layer provides a React-friendly API for accessing YouVersion data. It handles:
- React state management - Loading states, errors, and caching
- Context providers - Configuration, authentication, and reading session state
- Data fetching hooks - Simple hooks that return
{ data, loading, error, refetch } - No UI - Hooks are UI-agnostic and return data only
- YouVersionProvider - Core SDK configuration (API base URL, app key, theme)
- YouVersionAuthProvider - Authentication state and user info (automatically included when
includeAuth={true}) - ReaderProvider - Bible reading session state (current book, chapter, verse)
useChapter(),useBook(),usePassage(),useVerse()useVersion(),useVerseOfTheDay()useYVAuth()- Authentication and user managementuseChapterNavigation()- Navigate between chapters
All data hooks follow the same pattern:
{ data, loading, error, refetch }. This makes them predictable and easy to use.Layer 3: UI (@youversion/platform-react-ui)
Pre-built React components with complete styling and accessibility.
The UI layer provides production-ready components that handle common Bible reading experiences:
- Complete components - Ready to use with minimal configuration
- Tailwind CSS styling - Auto-injected, scoped, with dark mode support
- Radix UI primitives - Built-in accessibility
- Compound components - Flexible composition patterns
BibleTextView- Display a single Bible passageVerseOfTheDay- Daily verse cardBibleReader- Full reading experience with navigationBibleChapterPicker- Book and chapter selectionBibleVersionPicker- Bible version selectionBibleCard- Embeddable Bible passage cardYouVersionAuthButton- Sign in/out button
Dependency Rules
The architecture enforces strict dependency rules to maintain separation of concerns: Package Boundaries:- Core - Network + types (no React, no DOM)
- Hooks - React logic/state around core (no UI components)
- UI - Components and styling around hooks (no direct API calls)
When to Use Each Layer
Use Core When:
- Building a Node.js application
- Using a different framework (Vue, Angular, Svelte)
- Need fine-grained control over API requests
- Building server-side rendering without React
- Want framework-agnostic code
Use Hooks When:
- Building a React application with custom UI
- Need data fetching with loading/error states
- Want to integrate with your own design system
- Need authentication without pre-built UI components
Use UI When:
- Want to quickly add Bible reading features
- Don’t want to build custom UI components
- Need production-ready, accessible components
- Want dark mode and theming out of the box
Build Order
The monorepo uses Turborepo to enforce the correct build order:Important: Always rebuild dependent packages after modifying core or hooks. Use
turbo build --force if build cache causes issues.Unified Versioning
All three packages share the exact same version and are always released together:Example: Full Stack Usage
Here’s how the three layers work together in a complete application:- UI components call hooks from the Hooks layer
- Hooks call API clients from the Core layer
- Core makes HTTP requests to YouVersion API
- Data flows back up through the layers
Next Steps
Authentication
Learn about OAuth 2.0 PKCE flow and user management
Theming
Customize dark mode, colors, and styling
