# Oviato Documentation This file contains the complete Oviato documentation in a format optimized for Large Language Models (LLMs). Last updated: 2025-11-13T07:59:15.457Z --- # FILE: index.mdx # Welcome to Oviato Oviato provides secure, passwordless authentication for blockchain applications using WebAuthn passkeys. Build multi-chain wallet experiences with biometric authentication—no passwords or seed phrases required. ## Quick Links ## Choose Your SDK } title="Oviato Connect" href="/ovi-connect-sdk/what-is-ovi-connect" > React SDK with hooks, providers, and pre-built UI components. Perfect for Next.js and React applications. } title="Oviato SDK" href="/ovi-sdk/what-is-ovi-sdk" > Framework-agnostic JavaScript SDK. Works with Vue, Svelte, Angular, or vanilla JavaScript. ## Key Features - **Passkey Authentication** - Secure WebAuthn-based login with Face ID, Touch ID, or security keys - **Multi-Chain Support** - Bitcoin, Ethereum (soon) - **SSR Compatible** - Full support for Next.js App Router and server-side rendering - **TypeScript First** - Complete type safety and IntelliSense support - **Tiny Bundle** - Optimized for performance (~7-14 KB gzipped) - **Pre-built UI** - Drop-in components for rapid development ## Getting Started Get up and running with Oviato in 3 simple steps: 1. **[Create Your App](https://dashboard.oviato.com)** - Set up your application in the Oviato Dashboard 2. **Install SDK** - Choose between [@oviato/connect](/ovi-connect-sdk/installing-sdk) (React) or [@oviato/sdk](/ovi-sdk/installation) (Any framework) 3. **Integrate** - Add authentication to your app with just a few lines of code ```tsx // React example with @oviato/connect import { OviConnectProvider, ConnectButton } from '@oviato/connect/client'; ``` ## Resources - [Quick Start Guide](/getting-started/overview) - [Dashboard Setup](/developer-dashboard/setting-up-app) - [GitHub](https://github.com/oviato/sdk) - [Website](https://oviato.com) --- # FILE: getting-started/overview.mdx Welcome to Oviato! This guide will walk you through integrating Oviato authentication and wallet functionality into your application. ## What is Oviato? Oviato provides WebAuthn-based passkey authentication for multi-chain blockchain applications. Users can create accounts and sign transactions using biometrics (Face ID, Touch ID) or security keys—no passwords or seed phrases required. ## Getting Started in 3 Steps ### 1. Create Your App First, create an application in the [Oviato Developer Dashboard](https://dashboard.oviato.com): 1. Sign up or log in at [dashboard.oviato.com](https://dashboard.oviato.com) 2. Create a new application 3. Configure your app settings (name, logo, domains) 4. Copy your **App ID** - you'll need this for the SDK See the [Developer Dashboard](/docs/developer-dashboard/setting-up-app) section for detailed instructions. ### 2. Choose Your SDK Oviato offers two SDK options depending on your framework: #### For React/Next.js Apps: **@oviato/connect** Best for React applications. Includes hooks, providers, and pre-built UI components. ```bash npm install @oviato/connect ``` [→ @oviato/connect Documentation](/docs/ovi-connect-sdk/what-is-ovi-connect) #### For Other Frameworks: **@oviato/sdk** Framework-agnostic core SDK. Works with Vue, Svelte, Angular, or vanilla JavaScript. ```bash npm install @oviato/sdk ``` [→ @oviato/sdk Documentation](/docs/ovi-sdk/what-is-ovi-sdk) ### 3. Integrate Authentication #### Next.js Example ```tsx // app/layout.tsx import { OviConnectProvider } from "@oviato/connect/client"; export default function RootLayout({ children }) { return ( {children} ); } ``` ```tsx // app/page.tsx "use client"; import { useOviConnect, ConnectButton } from "@oviato/connect/client"; export default function Page() { const { session, disconnect } = useOviConnect(); if (!session) { return ; } return (

Connected: {session.address}

); } ``` #### Vanilla JavaScript Example ```javascript import { initialize, authenticate, getSession } from "@oviato/sdk"; // Initialize await initialize({ appId: "your-app-id", network: "bitcoinmainnet", }); // Authenticate const result = await authenticate(); if (result.status === "success") { const session = getSession(); console.log("Connected:", session.address); } ``` ## What's Next? - **[Developer Dashboard Guide](/developer-dashboard/setting-up-app)** - Set up your first app - **[@oviato/connect Docs](/ovi-connect-sdk/what-is-ovi-connect)** - React SDK with hooks and components - **[@oviato/sdk Docs](/ovi-sdk/what-is-ovi-sdk)** - Framework-agnostic core SDK ## Key Features - **Passkey Authentication** - Secure WebAuthn-based login with biometrics - **Multi-Chain Support** - Bitcoin, Ethereum (soon) - **SSR Compatible** - Works with Next.js App Router and all SSR frameworks - **TypeScript First** - Full type safety and IntelliSense - **Pre-built UI** - Drop-in components for rapid development - **Tiny Bundle** - Optimized for performance ## Need Help? - Drop us an email to: [support[at]oviato.com](mailto:support@oviato.com) --- # FILE: getting-started/using-llms.mdx Oviato's documentation is LLM-friendly to help developers integrate with Oviato faster using AI code editors. ## Use the Oviato docs llms-full.txt file You can provide your code editor with an `llms-full.txt` file to use Oviato's docs as context for your code. The following steps show how to do this for Cursor. ### Setup in Cursor 1. Navigate to **Cursor Settings → Features → Docs** 2. Select **"Add new doc"** and paste the following URL: ``` https://docs.oviato.com/llms-full.txt ``` 3. Use `@docs → Oviato` to reference Oviato's docs in your code ### What's Included The `llms-full.txt` file contains: - Complete getting started guides - Developer dashboard setup instructions - @oviato/connect SDK documentation (React/Next.js) - @oviato/sdk documentation (Framework-agnostic) - Authentication guides - Wallet operations and transaction signing - Code examples for all frameworks - Changelog and version history ### Benefits Using the LLM-friendly docs file allows you to: - **Get instant code suggestions** based on Oviato's latest documentation - **Ask questions** about Oviato features and get accurate answers - **Generate boilerplate code** that follows Oviato's best practices - **Debug faster** with context-aware suggestions - **Stay up-to-date** as the file is regenerated with each docs deployment ### Other AI Code Editors The `llms-full.txt` file works with any AI code editor that supports custom documentation sources: - **Cursor**: Add via Settings → Features → Docs - **GitHub Copilot**: Use with `@docs` in chat (if your editor supports it) - **Continue.dev**: Add as a context provider - **Any LLM**: Download the file and provide it as context ### Download the File You can also download the file directly and use it with any LLM: [Download llms-full.txt](https://docs.oviato.com/llms-full.txt) The file is automatically regenerated on every documentation deployment to ensure it stays current with the latest changes. ## Example Usage After adding the docs to Cursor, you can: ### Generate Auth Code ``` You: Using @docs Oviato, create a Next.js page with Oviato authentication Cursor: [Generates code using OviConnectProvider and useOviConnect hook] ``` ### Get Help with APIs ``` You: Using @docs Oviato, how do I sign a PSBT? Cursor: [Provides accurate answer from the documentation about signPsbt] ``` ### Debug Issues ``` You: Using @docs Oviato, why is my session undefined? Cursor: [Checks common issues from docs and suggests solutions] ``` ## Tips for Best Results - Always use `@docs Oviato` to reference the documentation explicitly - Be specific about which SDK you're using (@oviato/connect or @oviato/sdk) - Mention your framework (Next.js, Vue, etc.) for framework-specific guidance - Reference specific features (authentication, signing, transactions) for focused help ## Questions? If you encounter any issues with the LLM-friendly documentation: - Email us at [support@oviato.com](mailto:support@oviato.com) --- # FILE: developer-dashboard/setting-up-app.mdx This guide will walk you through creating and configuring your first application in the Oviato Developer Dashboard. ## Prerequisites Before you begin, you'll need: - An Oviato account (sign up at [dashboard.oviato.com](https://dashboard.oviato.com)) - Your application's domain(s) where you'll integrate Oviato ## Step 1: Access the Dashboard 1. Go to [dashboard.oviato.com](https://dashboard.oviato.com) 2. Sign in with your Oviato account 3. You'll land on the dashboard home page ## Step 2: Create a New Application 1. Click **"Create New App"** or **"New Application"** button 2. Fill in the required information: - **App Name**: A friendly name for your application (e.g., "My DeFi App"). This is an internal name and won't be visible to your users. - **Select Network**: Currently we support Bitcoin. More networks being added. ![Create an App](/developer-dashboard/create-app.png) ## Step 3: Configure App Settings After creating your app, you'll need to configure the following settings: ### Basic Information - **App Name**: Update anytime if needed - **App ID**: Auto Generated ID for your App. You will be using this ID in the SDK ```tsx // You'll use this App ID in your code ``` ### Allowed Domains Add the domains where your app will be hosted: 1. Click **"Add Domain"** 2. Enter your domain (e.g., `https://myapp.com` or `http://localhost:3000` for development) 3. Click **"Add"** **Important**: - Include both production and development domains - Localhost addresses are supported for testing - Wildcards are not supported for security reasons ### Branding (Optional) Customize how Oviato authentication appears to your users: - **Logo**: Upload your app logo (recommended: 200x200px PNG or SVG) - **Brand Color**: Choose your primary brand color - **Theme**: Select light or dark theme These settings affect the authentication modal and wallet UI shown to your users. ## Step 4: Copy Your App ID 1. In your app settings, locate the **App ID** field 2. Click the copy icon or select and copy the ID 3. Save this somewhere secure - you'll need it for SDK integration ## Step 5: Environment Selection Oviato supports multiple environments: - **Production**: For live applications - **Staging**: For testing before deployment You can switch between environments in the dashboard sidebar. ## Step 6: SDK Integration Now that your app is configured, integrate the Oviato SDK: ### For React/Next.js: ```bash npm install @oviato/connect ``` ```tsx import { OviConnectProvider } from "@oviato/connect/client"; {children} ; ``` [→ Full @oviato/connect Documentation](/docs/ovi-connect-sdk/what-is-ovi-connect) ### For Other Frameworks: ```bash npm install @oviato/sdk ``` ```javascript import { initialize } from "@oviato/sdk"; await initialize({ appId: "your-app-id", network: "bitcoinmainnet", }); ``` [→ Full @oviato/sdk Documentation](/docs/ovi-sdk/what-is-ovi-sdk) ## Managing Your App ### View App Analytics The dashboard provides insights into: - Total users - Authentication events - Transaction volume - Network usage ### Update App Settings You can update your app settings anytime: 1. Select your app from the sidebar 2. Navigate to the settings you want to change 3. Make your updates 4. Changes take effect immediately ### Multiple Apps You can create and manage multiple applications: - Each app has its own App ID - Apps can have different configurations - Switch between apps using the sidebar dropdown ## Security Best Practices - **Never expose your App ID in public repositories** (if it includes sensitive configuration) - **Use environment variables** to store your App ID ```bash # .env.local NEXT_PUBLIC_OVIATO_APP_ID=your-app-id ``` - **Regularly review** allowed domains to ensure only authorized domains can use your app - **Monitor** your app's usage in the analytics dashboard ## Troubleshooting ### "Domain not allowed" error - Verify the domain is added to your allowed domains list - Check for typos in the domain URL - Ensure you're using the correct protocol (http/https) ### App ID not working - Confirm you copied the entire App ID - Check that you're using the correct environment (staging vs production) - Verify the SDK is properly initialized ## Next Steps - **[Integrate @oviato/connect](/ovi-connect-sdk/installing-sdk)** - Install and setup the React SDK - **[Integrate @oviato/sdk](/ovi-sdk/installation)** - Install the framework-agnostic SDK --- # FILE: ovi-connect-sdk/what-is-ovi-connect.mdx **@oviato/connect** is Oviato's React SDK that provides hooks, providers, and pre-built UI components for seamless integration of passkey authentication and wallet functionality in React and Next.js applications. ## Why @oviato/connect? @oviato/connect is designed specifically for React developers who want: - **React-First Architecture**: Hooks, context providers, and React components - **SSR/Next.js Support**: Full compatibility with Next.js App Router, Pages Router, and SSR - **Pre-built UI Components**: Drop-in authentication buttons and modals - **Type Safety**: Complete TypeScript support - **Zero Config**: Works out of the box with sensible defaults ## When to Use @oviato/connect Choose **@oviato/connect** if you're building with: - ✅ React (Create React App, Vite) - ✅ Next.js (App Router or Pages Router) - ✅ Remix - ✅ Any React-based framework For **non-React frameworks** (Vue, Svelte, Angular, vanilla JS), use [@oviato/sdk](/docs/ovi-sdk/what-is-ovi-sdk) instead. ## Key Features ### React Hooks Access authentication state and wallet operations through intuitive hooks: ```tsx import { useOviConnect } from "@oviato/connect/client"; function MyComponent() { const { session, isLoading, disconnect } = useOviConnect(); if (isLoading) return
Loading...
; if (!session) return
Not connected
; return
Connected: {session.address}
; } ``` ### Pre-built Components Drop-in UI components for authentication: ```tsx import { ConnectButton } from "@oviato/connect/client"; console.log("Connected:", data.address)} />; ``` ### Provider Pattern Wrap your app with `OviConnectProvider` to manage authentication state: ```tsx import { OviConnectProvider } from "@oviato/connect/client"; ; ``` ### SSR Safe Works seamlessly with server-side rendering: - Proper hydration handling - No flash of unauthenticated content - Automatic session restoration ### Built on @oviato/sdk @oviato/connect is built on top of [@oviato/sdk](/docs/ovi-sdk/what-is-ovi-sdk), giving you access to all core functionality while providing React-specific optimizations and patterns. ## Package Structure @oviato/connect provides two optimized entry points: ### 1. Core Entry (`@oviato/connect`) Server-safe utilities and types (re-exports from @oviato/sdk): ```ts import { // Core functions initialize, authenticate, login, register, signMessage, sendTransfer, switchNetwork, signPsbt, // Session management getSession, clearSession, isAuthenticated, // Types type UserSession, type OviatoConfig, } from "@oviato/connect"; ``` ### 2. Client Entry (`@oviato/connect/client`) React components and hooks (client-only with `'use client'` directive): ```tsx import { // Provider OviConnectProvider, // Hooks useOviConnect, // Components ConnectButton, Connect, Button, } from "@oviato/connect/client"; ``` This separation enables optimal tree-shaking and SSR compatibility. ## Quick Comparison | Feature | @oviato/connect | @oviato/sdk | | ----------------- | --------------- | --------------- | | **Best For** | React/Next.js | Any framework | | **Hooks** | ✅ Yes | ❌ No | | **Provider** | ✅ Yes | ❌ No | | **UI Components** | ✅ Yes | ❌ No | | **Bundle Size** | ~14 KB | ~7.7 KB | | **TypeScript** | ✅ Full support | ✅ Full support | | **SSR Support** | ✅ Optimized | ✅ Core support | ## Architecture @oviato/connect follows industry-standard React patterns: ``` @oviato/connect ├── Core Functions (from @oviato/sdk) ├── React Provider (OviConnectProvider) │ └── Context Management ├── React Hooks (useOviConnect) │ └── State Access └── UI Components ├── ConnectButton ├── Connect └── Utility Components ``` ## What's Included? ### Authentication - Smart authentication (auto-detect login vs register) - Passkey-based login - User registration with biometrics ### Wallet Operations - Message signing - Transaction sending - PSBT signing (Bitcoin) - Network switching ### Session Management - Automatic session restoration - Secure session storage - Session state management ### RPC Client - Balance queries - Transaction history - OVI.ID username resolution - Custom RPC calls ## Installation ```bash npm install @oviato/connect # or pnpm add @oviato/connect # or yarn add @oviato/connect ``` ## Next Steps - **[Installing @oviato/connect](/ovi-connect-sdk/installing-sdk)** - Installation and setup - **[Quick Start Guide](/getting-started/overview)** - Get started in minutes --- # FILE: ovi-connect-sdk/installing-sdk.mdx This guide will walk you through installing and setting up @oviato/connect in your React or Next.js application. ## Prerequisites Before you begin, make sure you have: 1. **An Oviato App ID** - Create one at [dashboard.oviato.com](https://dashboard.oviato.com) - See [Setting Up Your App](/docs/developer-dashboard/setting-up-app) for instructions 2. **Node.js 16+** installed 3. **A React or Next.js project** (supports React 18+) ## Installation Install @oviato/connect using your preferred package manager: ```bash # npm npm install @oviato/connect # pnpm pnpm add @oviato/connect # yarn yarn add @oviato/connect # bun bun add @oviato/connect ``` ## Setup by Framework ### Next.js App Router (Recommended) #### Step 1: Add Provider to Root Layout Create or update your root layout to include the `OviConnectProvider`: ```tsx title="app/layout.tsx" import { OviConnectProvider } from "@oviato/connect/client"; export default function RootLayout({ children, }: { children: React.ReactNode; }) { return ( {children} ); } ``` #### Step 2: Create Environment Variables Create a `.env.local` file in your project root: ```bash title=".env.local" NEXT_PUBLIC_OVIATO_APP_ID=your-app-id-here ``` #### Step 3: Use in Client Components Create a client component to use Oviato authentication: ```tsx title="app/page.tsx" "use client"; import { useOviConnect, ConnectButton } from "@oviato/connect/client"; export default function HomePage() { const { session, isLoading, disconnect } = useOviConnect(); if (isLoading) { return
Loading...
; } if (!session) { return (

Welcome to My App

); } return (

Welcome, {session.username}!

Address: {session.address}

Network: {session.network}

); } ``` ### Next.js Pages Router #### Step 1: Add Provider to \_app.tsx ```tsx title="pages/_app.tsx" import type { AppProps } from "next/app"; import { OviConnectProvider } from "@oviato/connect/client"; export default function App({ Component, pageProps }: AppProps) { return ( ); } ``` #### Step 2: Use in Pages ```tsx title="pages/index.tsx" import { useOviConnect, ConnectButton } from "@oviato/connect/client"; export default function HomePage() { const { session, disconnect } = useOviConnect(); return (
{session ? (

Connected: {session.address}

) : ( )}
); } ``` ### Create React App / Vite #### Step 1: Add Provider to App Root ```tsx title="src/App.tsx" import { OviConnectProvider } from "@oviato/connect/client"; import HomePage from "./pages/HomePage"; function App() { return ( ); } export default App; ``` #### Step 2: Use in Components ```tsx title="src/pages/HomePage.tsx" import { useOviConnect, ConnectButton } from "@oviato/connect/client"; export default function HomePage() { const { session, disconnect } = useOviConnect(); return (
{session ? (

Connected: {session.address}

) : ( )}
); } ``` #### Environment Variables (Vite) Create a `.env.local` file: ```bash title=".env.local" VITE_OVIATO_APP_ID=your-app-id-here ``` Use in your code: ```tsx ``` ## Provider Configuration The `OviConnectProvider` accepts several configuration options: ```tsx {children} ``` ### Configuration Options | Option | Type | Default | Description | | ------------- | ------------------- | ------------------ | -------------------------- | | `appId` | `string` | **Required** | Your Oviato application ID | | `network` | `string` | `'bitcoinmainnet'` | Default blockchain network | | `theme` | `'light' \| 'dark'` | System preference | UI theme for auth modal | | `accentColor` | `string` | `'#3B82F6'` | Primary brand color (hex) | | `logoUrl` | `string` | Oviato logo | Your app logo URL | | `name` | `string` | `'App'` | Your app name | ### Supported Networks - `bitcoinmainnet` - Bitcoin Mainnet - `bitcointestnet` - Bitcoin Testnet - `ethmainnet` - Ethereum Mainnet (soon) - `ethsepolia` - Ethereum Sepolia Testnet (soon) ## Verify Installation Create a simple test to verify everything is working: ```tsx "use client"; // Only needed for Next.js App Router import { useOviConnect, ConnectButton } from "@oviato/connect/client"; export default function TestPage() { const { session, ready, isLoading } = useOviConnect(); return (

Oviato Connection Test

SDK Ready: {ready ? "✅" : "❌"}

Loading: {isLoading ? "Yes" : "No"}

Session: {session ? "✅ Connected" : "❌ Not connected"}

{!session && } {session && (

Username: {session.username}

Address: {session.address}

)}
); } ``` ## TypeScript Configuration @oviato/connect includes full TypeScript definitions. No additional setup required! Import types as needed: ```tsx import type { UserSession, OviatoConfig, BridgeResponse, OviConnectProviderProps, } from "@oviato/connect"; import type { UseOviConnectReturn } from "@oviato/connect/client"; ``` ## Troubleshooting ### "Cannot find module '@oviato/connect/client'" Make sure you're importing from the correct entry point: - ✅ `from '@oviato/connect/client'` (for React components/hooks) - ✅ `from '@oviato/connect'` (for core functions/types) ### "'use client' directive" errors If you see errors about client directives: 1. Ensure you're using Next.js 13+ with App Router 2. Add `'use client'` at the top of components using hooks 3. Make sure you're importing from `/client` entry point ### Session not persisting Check that: 1. Your domain is added to allowed domains in the dashboard 2. Cookies are enabled in the browser 3. You're using HTTPS in production (required for WebAuthn) ### Type errors with session Make sure TypeScript can resolve the types: ```tsx import type { UserSession } from "@oviato/connect"; const session: UserSession | null = getSession(); ``` ## Next Steps - **[Using Hooks](/ovi-connect-sdk/using-hooks)** - Learn about useOviConnect and useOviStore - **[Components Reference](/ovi-connect-sdk/components)** - Explore pre-built UI components - **[Signing Messages](/ovi-connect-sdk/signing-messages)** - Sign messages with the wallet - **[Signing Transactions](/ovi-connect-sdk/signing-transactions)** - Send transactions --- # FILE: ovi-connect-sdk/using-hooks.mdx @oviato/connect provides React hooks to access authentication state and SDK functionality in your React components. ## useOviConnect Hook The primary hook for accessing Oviato authentication state and methods. Must be used inside `OviConnectProvider`. ### Basic Usage ```tsx import { useOviConnect } from '@oviato/connect/client'; function MyComponent() { const { session, isLoading, disconnect } = useOviConnect(); if (isLoading) { return
Loading...
; } if (!session) { return
Not connected
; } return (

Address: {session.address}

); } ``` ### Return Values The `useOviConnect` hook returns an object with the following properties: ```typescript { // Current user session (null if not authenticated) session: Session | null; // Whether SDK is initializing isLoading: boolean; // Whether SDK is ready to use ready: boolean; // Update the session setSession: (session: Session) => void; // Disconnect and clear session disconnect: () => void; // Get current initialization options getInitOptions: () => InitOptions | null; } ``` ### Session Object When authenticated, the session object contains: ```typescript type Session = { address: string; // Wallet address publicKey: string; // Public key (hex) username?: string; // OVI.ID username (if set) network: Network; // Current network appId: string; // Your app ID userId: string; // Oviato user ID createdAt: number; // Timestamp }; ``` ### Complete Example ```tsx 'use client'; import { useOviConnect } from '@oviato/connect/client'; import { authenticate, signMessage } from '@oviato/connect'; export default function WalletPage() { const { session, isLoading, ready, disconnect } = useOviConnect(); const handleConnect = async () => { const result = await authenticate(); if (result.status === 'error') { console.error('Auth failed:', result.message); } }; const handleSign = async () => { const result = await signMessage('Hello from Oviato!'); if (result.status === 'success') { console.log('Signature:', result.data.signature); } }; if (isLoading || !ready) { return
Loading Oviato...
; } if (!session) { return (

Connect Your Wallet

); } return (

Connected

Address: {session.address}

{session.username &&

Username: @{session.username}

}

Network: {session.network}

); } ``` ## useOviStore Hook Advanced hook for accessing the Zustand store directly. Provides more granular control over state subscriptions. ### Basic Usage ```tsx import { useOviStore } from '@oviato/connect'; function MyComponent() { // Subscribe to specific state const session = useOviStore(state => state.session); const isAuthenticated = useOviStore(state => state.isAuthenticated()); return (
{isAuthenticated ? (

Address: {session?.address}

) : (

Not connected

)}
); } ``` ### When to Use useOviStore Use `useOviStore` when you need: - Fine-grained subscriptions to avoid unnecessary re-renders - Access to store methods directly - Integration with other state management solutions - Advanced state debugging For most cases, `useOviConnect` is recommended as it provides a simpler API. ### Available State ```typescript { // Session state session: Session | null; isAuthenticated: () => boolean; // Loading state isLoading: boolean; ready: boolean; // Methods setSession: (session: Session) => void; clearSession: () => void; setLoading: (loading: boolean) => void; setReady: (ready: boolean) => void; } ``` ### Performance Optimization ```tsx import { useOviStore } from '@oviato/connect'; function AddressDisplay() { // Only re-renders when address changes const address = useOviStore(state => state.session?.address); return
{address || 'Not connected'}
; } function LoadingIndicator() { // Only re-renders when loading state changes const isLoading = useOviStore(state => state.isLoading); return isLoading ? : null; } ``` ### Combining Multiple State Values ```tsx import { useOviStore } from '@oviato/connect'; function WalletInfo() { // Efficient: single subscription for multiple values const { address, network, username } = useOviStore(state => ({ address: state.session?.address, network: state.session?.network, username: state.session?.username, })); return (

Address: {address}

Network: {network}

{username &&

Username: @{username}

}
); } ``` ## Hook Rules Both hooks must follow React's rules of hooks: - ✅ Must be used inside `OviConnectProvider` - ✅ Only call at the top level of components - ✅ Only call from React function components or custom hooks - ❌ Don't call inside loops, conditions, or nested functions ### Error: Hook Used Outside Provider ```tsx // ❌ Wrong: Used outside provider function App() { const { session } = useOviConnect(); // Error! return
{session?.address}
; } // ✅ Correct: Used inside provider function App() { return ( ); } function MyComponent() { const { session } = useOviConnect(); // Works! return
{session?.address}
; } ``` ## TypeScript Support Both hooks have full TypeScript support: ```tsx import { useOviConnect } from '@oviato/connect/client'; import type { Session } from '@oviato/connect'; function MyComponent() { const { session }: { session: Session | null } = useOviConnect(); // TypeScript knows session can be null if (session) { // Here, TypeScript knows session is Session console.log(session.address); // ✅ Type-safe } } ``` ## Next Steps - **[Components Reference](/ovi-connect-sdk/components)** - Explore pre-built UI components - **[Signing Messages](/ovi-connect-sdk/signing-messages)** - Sign messages with hooks - **[Signing Transactions](/ovi-connect-sdk/signing-transactions)** - Send transactions with hooks --- # FILE: ovi-connect-sdk/components.mdx @oviato/connect provides pre-built React components for authentication and wallet management. These components handle the complex UI and authentication flow, allowing you to integrate Oviato quickly. ## Connect A pre-built authentication form with username input and availability checking. This is the easiest way to add Oviato authentication to your app. ### Basic Usage ```tsx import { Connect } from '@oviato/connect/client'; function MyComponent() { return ( { console.log('Connected:', data.address); console.log('Public Key:', data.publicKey); }} /> ); } ``` ### Props ```typescript interface ConnectProps { /** Callback fired on successful authentication */ callback?: (data: { address: string; publicKey: string; }) => void; } ``` ### Features The `Connect` component includes: - **Username input** with real-time validation - **Availability checking** - verifies username is not taken - **Auto login/register** - automatically determines if user is new or existing - **Loading states** - shows feedback during authentication - **Built-in styling** - works out of the box with minimal setup ### Complete Example ```tsx 'use client'; import { Connect } from '@oviato/connect/client'; import { useOviConnect } from '@oviato/connect/client'; export default function AuthPage() { const { session } = useOviConnect(); if (session) { return (

Already connected as {session.address}

); } return (

Connect Your Wallet

{ console.log('Successfully connected!'); console.log('Address:', data.address); // Redirect or update UI window.location.href = '/dashboard'; }} />
); } ``` ### Styling The `Connect` component uses class names that you can override: ```css /* Override default styles */ .ovi-connect-form { /* Form container */ } .ovi-connect-input { /* Username input */ } .ovi-connect-button { /* Submit button */ } .ovi-connect-status { /* Status message (username availability) */ } ``` ### Multi-Step Form Example ```tsx 'use client'; import { useState } from 'react'; import { Connect } from '@oviato/connect/client'; export default function OnboardingPage() { const [step, setStep] = useState(1); return (
{step === 1 && (

Step 1: Welcome

)} {step === 2 && (

Step 2: Connect Wallet

{ setStep(3); }} />
)} {step === 3 && (

You're all set!

)}
); } ``` ## ConnectButton A flexible authentication button that triggers the Oviato passkey flow. Use this when you want to build your own UI but need a simple connect button. ### Basic Usage ```tsx import { ConnectButton } from '@oviato/connect/client'; function MyComponent() { return ( { console.log('Connected:', data.address); }} onError={(error) => { console.error('Failed:', error); }} /> ); } ``` ### Props ```typescript interface ConnectButtonProps { /** Text for default button (default: "Signup / Login with Passkey") */ text?: string; /** Custom children to render instead of default button */ children?: ReactNode; /** Callback fired on successful authentication */ onSuccess?: (data: { address: string; publicKey: string; username: string; }) => void; /** Callback fired on authentication error */ onError?: (error: Error) => void; /** Custom className for default button (ignored if children provided) */ className?: string; /** Authentication method (default: 'iframe') */ method?: 'iframe' | 'popup'; } ``` ### Custom Children Use your own button component: ```tsx import { ConnectButton } from '@oviato/connect/client'; function MyComponent() { return ( console.log(data)}> ); } ``` ### With Callback Handling ```tsx import { ConnectButton } from '@oviato/connect/client'; import { useState } from 'react'; function MyComponent() { const [error, setError] = useState(null); return (
{ console.log('Address:', data.address); console.log('Username:', data.username); }} onError={(error) => { setError(error.message); }} /> {error &&

{error}

}
); } ``` ### Popup vs Iframe Method Choose between popup or iframe authentication: ```tsx // Iframe (default) - opens in modal overlay // Popup - opens in new browser window ``` **When to use each:** - **Iframe** (recommended): Better UX, stays in-page, works on mobile - **Popup**: Use when iframe is blocked or you need popup-specific behavior ### Custom Auth Flow Example ```tsx 'use client'; import { ConnectButton, useOviConnect } from '@oviato/connect/client'; export default function AuthPage() { const { session, disconnect } = useOviConnect(); if (session) { return (

Connected: {session.address}

); } return (

Welcome to My App

Connect your wallet to get started

{ console.log('Connected successfully!'); }} />
); } ``` ## Styling Components All components support className and style props for customization: ```tsx // Using className // Using inline styles // Using custom children with full control ``` ## TypeScript Support All components have full TypeScript support: ```tsx import type { ConnectButtonProps, ConnectProps } from '@oviato/connect/client'; const buttonProps: ConnectButtonProps = { text: 'Connect', onSuccess: (data) => { // data is fully typed console.log(data.address); }, }; const connectProps: ConnectProps = { callback: (data) => { // data is fully typed console.log(data.publicKey); }, }; ``` ## Next Steps - **[Using Hooks](/ovi-connect-sdk/using-hooks)** - Learn about useOviConnect and useOviStore - **[Signing Messages](/ovi-connect-sdk/signing-messages)** - Sign messages with the wallet - **[Signing Transactions](/ovi-connect-sdk/signing-transactions)** - Send transactions --- # FILE: ovi-connect-sdk/signing-messages.mdx Learn how to sign arbitrary messages using @oviato/connect in React applications. ## Overview Message signing allows users to cryptographically prove ownership of their wallet without sending a transaction. This is useful for: - Authentication challenges - Proof of ownership - Off-chain signatures - Message verification ## Basic Usage ### With Core Function Use the `signMessage` function directly: ```tsx "use client"; import { useState } from "react"; import { useOviConnect } from "@oviato/connect/client"; import { signMessage } from "@oviato/connect"; export default function SignMessage() { const { session } = useOviConnect(); const [signature, setSignature] = useState(""); const handleSign = async () => { const result = await signMessage("Hello, Oviato!"); if (result.status === "success") { setSignature(result.data.signature); console.log("Message:", result.data.message); console.log("Public Key:", result.data.publicKey); } }; if (!session) { return
Please connect your wallet first
; } return (
{signature && (

Signature: {signature}

)}
); } ``` ## Response Type The `signMessage` function returns a `BridgeResponse`: ```typescript type SignMessageResponse = { status: "success" | "error"; data?: { message: string; // Original message signature: string; // Cryptographic signature publicKey: string; // Public key used for signing }; message?: string; // Error message if failed }; ``` ## Complete Example Here's a complete example with input and error handling: ```tsx "use client"; import { useState } from "react"; import { useOviConnect } from "@oviato/connect/client"; import { signMessage } from "@oviato/connect"; export default function MessageSigner() { const { session } = useOviConnect(); const [message, setMessage] = useState(""); const [signature, setSignature] = useState(""); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); const handleSign = async () => { if (!message.trim()) { setError("Please enter a message"); return; } setIsLoading(true); setError(""); setSignature(""); const result = await signMessage(message); if (result.status === "success") { setSignature(result.data.signature); } else { setError(result.message || "Failed to sign message"); } setIsLoading(false); }; if (!session) { return (

Please connect your wallet to sign messages

); } return (

Sign Message

Address: {session.address}