### Install All Buoy.gg Tools Source: https://github.com/buoy-gg/buoy/blob/main/README.md Install all available Buoy.gg tools simultaneously using npm. This command installs the core package along with all listed tools. ```bash npm i @buoy-gg/{core,network,storage,env,react-query,route-events,debug-borders,highlight-updates,perf-monitor,events,console,redux,zustand,jotai,impersonate,image-overlay} ``` -------------------------------- ### Install Buoy.gg Core Package Source: https://github.com/buoy-gg/buoy/blob/main/README.md Install the core package using npm. Alternatively, yarn, pnpm, or bun can be used. ```bash npm install @buoy-gg/core # or: yarn add / pnpm add / bun add ``` -------------------------------- ### Install Bench with Native Modules Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/perf-monitor.md Install Bench along with required native modules for React Native performance monitoring. Rebuild your app with a custom dev build after installation. ```bash npm install @buoy-gg/perf-monitor react-native-reanimated react-native-worklets react-native-performance-toolkit react-native-nitro-modules ``` ```bash yarn add @buoy-gg/perf-monitor react-native-reanimated react-native-worklets react-native-performance-toolkit react-native-nitro-modules ``` ```bash pnpm add @buoy-gg/perf-monitor react-native-reanimated react-native-worklets react-native-performance-toolkit react-native-nitro-modules ``` ```bash bun add @buoy-gg/perf-monitor react-native-reanimated react-native-worklets react-native-performance-toolkit react-native-nitro-modules ``` -------------------------------- ### Install a Buoy Tool Package Source: https://github.com/buoy-gg/buoy/blob/main/docs/floating-devtools.md Install a Buoy tool package using npm to automatically register it with the floating menu. No additional imports or configuration are needed. ```bash npm install @buoy-gg/network ``` -------------------------------- ### Install React Buoy Core Package Source: https://github.com/buoy-gg/buoy/blob/main/AGENTS.md Install the core package for React Buoy using npm. This is the first step before rendering the FloatingDevTools component. ```bash npm install @buoy-gg/core ``` -------------------------------- ### Impersonate Tool Configuration with Callbacks Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/impersonate.md Example of creating an impersonate tool instance with custom callbacks for clearing AsyncStorage and MMKV. The `onSearchUsers` callback is also provided. ```typescript const impersonateTool = createImpersonateTool({ onSearchUsers: searchUsers, // Clear AsyncStorage (filter out keys you want to keep) onClearAsyncStorage: async () => { const keys = await AsyncStorage.getAllKeys(); const appKeys = keys.filter(k => !k.startsWith('@buoy/')); await AsyncStorage.multiRemove(appKeys); }, // Clear MMKV onClearMMKV: () => { const keys = storage.getAllKeys(); keys.filter(k => !k.startsWith('@buoy/')).forEach(k => storage.delete(k)); }, }); ``` -------------------------------- ### Setup Jotai DevTools with Default Store Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/jotai.md Call `watchAtoms` once at module scope, passing the default Jotai store and a map of your atoms. This setup automatically registers atoms for inspection without modifying existing atoms or requiring wrappers. ```tsx import { getDefaultStore, } from 'jotai'; import { watchAtoms } from '@buoy-gg/jotai'; import { countAtom } from './atoms/count'; import { authAtom } from './atoms/auth'; import { cartAtom } from './atoms/cart'; watchAtoms(getDefaultStore(), { countAtom, authAtom, cartAtom, }); ``` -------------------------------- ### Setup FloatingDevTools with Zustand Stores Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/zustand.md Pass your Zustand stores directly to the FloatingDevTools component via the `zustandStores` prop. This is the primary method for integrating the dev tools. ```tsx import { FloatingDevTools } from '@buoy-gg/core'; import { useCounterStore } from './stores/counter'; import { useAuthStore } from './stores/auth'; import { useCartStore } from './stores/cart'; const stores = { counterStore: useCounterStore, authStore: useAuthStore, cartStore: useCartStore, }; return ; ``` -------------------------------- ### Register Multiple Custom Tools Source: https://github.com/buoy-gg/buoy/blob/main/docs/custom-tools.md This example demonstrates how to register multiple custom tools, including 'Auth', 'Feature Flags', and 'Analytics', each with a name, component, icon, and description. ```tsx ``` -------------------------------- ### Express Middleware for Impersonation Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/impersonate.md An example of Express middleware to check for an impersonation header, verify user permissions, and set the effective user ID for the request. ```javascript // Express middleware example function impersonateMiddleware(req, res, next) { const impersonateUserId = req.headers['x-impersonate-user-id']; if (impersonateUserId) { // Verify the authenticated user has permission to impersonate if (!req.user.isAdmin) { return res.status(403).json({ error: 'Impersonation not allowed' }); } // Switch context to impersonated user req.effectiveUserId = impersonateUserId; } else { req.effectiveUserId = req.user.id; } next(); } ``` -------------------------------- ### Setup Jotai DevTools with Custom Store Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/jotai.md When using a custom Jotai store with a ``, pass the custom store instance to `watchAtoms` along with your atoms. This ensures the DevTools monitor the correct store. ```tsx import { createStore, Provider, } from 'jotai'; import { watchAtoms } from '@buoy-gg/jotai'; import { countAtom, authAtom } from './atoms'; const myStore = createStore(); watchAtoms(myStore, { countAtom, authAtom }); export function App() { return ( ); } ``` -------------------------------- ### Add FloatingDevTools to Your App Source: https://github.com/buoy-gg/buoy/blob/main/README.md Import and render the FloatingDevTools component in your React application. This will automatically display the installed tools in a floating menu. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; export default function App() { return ( <> {/* Your app */} ); } ``` -------------------------------- ### Conditionally Show DevTools Based on User Role Source: https://github.com/buoy-gg/buoy/blob/main/docs/quick-start.md Control the visibility of FloatingDevTools based on user authentication and roles. This example shows devtools only for 'admin', 'qa' roles, or users with an email ending in '@yourcompany.com'. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; export default function App() { const { user } = useAuth(); // Only render for internal users, admins, or QA const showDevTools = user?.role === "admin" || user?.role === "qa" || user?.email?.endsWith("@yourcompany.com"); return ( <> {showDevTools && ( )} ); } ``` -------------------------------- ### Custom Redux Middleware Options for Buoy Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/redux.md Configure custom middleware for Buoy to control history size and ignore specific actions. This is useful for fine-grained control over what gets captured. ```tsx import { createBuoyReduxMiddleware, withBuoyDevTools } from '@buoy-gg/redux'; const customMiddleware = createBuoyReduxMiddleware({ maxActions: 500, // History size (default: 200) ignoreActions: [ 'persist/PERSIST', 'persist/REHYDRATE', ], }); const store = configureStore({ reducer: withBuoyDevTools(rootReducer), middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(customMiddleware), }); ``` -------------------------------- ### CreateEnvTool Configuration Options Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/env.md Provides options for configuring the `createEnvTool` function, including name, description, color preset, ID, and required environment variables. ```typescript createEnvTool({ name?: string; // default: "ENV" description?: string; colorPreset?: "orange" | "cyan" | "purple" | "pink" | "yellow" | "green"; // default: "green" id?: string; // default: "env" requiredEnvVars?: RequiredEnvVar[]; enableSharedModalDimensions?: boolean; }); ``` -------------------------------- ### Create and Configure Impersonate Tool Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/impersonate.md Initialize the Impersonate tool by providing a function to search for users. This function should return a list of user objects with specific properties. The tool is then integrated into the application's development tools. ```tsx import { createImpersonateTool } from '@buoy-gg/impersonate'; import { FloatingDevTools } from '@buoy-gg/dev-tools'; const impersonateTool = createImpersonateTool({ // Required: How to search for users onSearchUsers: async (query) => { const response = await api.searchUsers({ email: query }); return response.users.map(user => ({ id: user.id, displayName: user.name, email: user.email, avatarUrl: user.avatar, metadata: { role: user.role }, })); }, }); function App() { return ( <> ); } ``` -------------------------------- ### Basic FloatingDevTools Usage Source: https://github.com/buoy-gg/buoy/blob/main/docs/floating-devtools.md Import and render the FloatingDevTools component with your license key. Ensure it's placed after your main app content. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; function App() { return ( <> ); } ``` -------------------------------- ### Create Environment Tool with Custom Configuration Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/env.md Use `createEnvTool` with the `envVar` builder to define required environment variables, their types, expected values, and descriptions for validation. ```tsx import { createEnvTool, envVar } from "@buoy-gg/env"; const envTool = createEnvTool({ requiredEnvVars: [ envVar("EXPO_PUBLIC_API_URL").exists(), envVar("EXPO_PUBLIC_DEBUG_MODE").withType("boolean").build(), envVar("EXPO_PUBLIC_ENVIRONMENT").withValue("development").build(), envVar("EXPO_PUBLIC_MAX_RETRIES") .withType("number") .withDescription("Maximum API retry attempts") .build(), ], }); ``` -------------------------------- ### Initialize Buoy MCP Server Source: https://github.com/buoy-gg/buoy/blob/main/docs/quick-start.md Initialize the Buoy MCP Server to connect your running app with AI code editors like Claude Code or Cursor. This command sets up the necessary integration. ```bash npx -y @buoy-gg/mcp@latest init ``` -------------------------------- ### Wrap Zustand Store with buoyDevTools Middleware Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/zustand.md Use the `buoyDevTools` middleware to wrap your Zustand stores for precise partial state capture and timing data. This is useful for performance monitoring and detailed state change analysis. ```tsx import { create } from 'zustand'; import { buoyDevTools } from '@buoy-gg/zustand'; const useCounterStore = create( buoyDevTools( (set) => ({ count: 0, increment: () => set((s) => ({ count: s.count + 1 })), }), { name: 'counterStore' } ) ); ``` -------------------------------- ### Manual MCP Configuration Source: https://github.com/buoy-gg/buoy/blob/main/docs/mcp.md Add this JSON configuration to your MCP config to manually wire the buoy server. ```json { "mcpServers": { "buoy": { "type": "stdio", "command": "npx", "args": ["-y", "@buoy-gg/mcp@latest"] } } } ``` -------------------------------- ### Enable Pro Features with License Key Source: https://github.com/buoy-gg/buoy/blob/main/README.md To unlock Pro features in production builds, add the licenseKey prop to the FloatingDevTools component. ```tsx ``` -------------------------------- ### Enable Full Time-Travel with Buoy DevTools Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/redux.md Wrap your root reducer with `withBuoyDevTools` to enable full time-travel capabilities in your Redux store. This allows you to jump to past states. ```tsx import { configureStore } from '@reduxjs/toolkit'; import { withBuoyDevTools } from '@buoy-gg/redux'; const store = configureStore({ reducer: withBuoyDevTools(rootReducer), }); ``` -------------------------------- ### Importing Redux Utilities from Buoy Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/redux.md This snippet shows the primary imports available for integrating Buoy with Redux. These include utilities for auto-instrumentation, manual middleware creation, time-travel debugging features, hooks, and history adapters. ```tsx import { // Auto-instrumentation (used internally, rarely needed) instrumentStore, isStoreInstrumented, // Manual middleware (optional, for advanced config) buoyReduxMiddleware, createBuoyReduxMiddleware, // Time-travel (optional) withBuoyDevTools, jumpToState, replayAction, // Hooks useReduxActions, useAutoInstrumentRedux, // History adapter (for custom integrations) reduxHistoryAdapter, createReduxHistoryAdapter, } from '@buoy-gg/redux'; ``` -------------------------------- ### Register SecureStore Keys Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/storage.md Register keys for Expo SecureStore to make them visible in the Storage Explorer. Pass the SecureStore module and an array of keys or objects with key configurations. ```typescript import * as SecureStore from "expo-secure-store"; import { registerSecureStoreKeys } from "@buoy-gg/storage"; registerSecureStoreKeys(SecureStore, [ "auth.accessToken", { key: "session", keychainService: "com.myapp.auth" }, // Biometric-protected keys are listed but never auto-read (no surprise Face ID prompts) { key: "pin", requireAuthentication: true }, ]); ``` -------------------------------- ### Add Custom Debugging Tools Source: https://github.com/buoy-gg/buoy/blob/main/docs/floating-devtools.md Integrate custom debugging tools by providing an array of tool configurations to the customTools prop. Each tool requires a name, component, and optionally an icon. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; const FeatureFlagTool = () => ( Toggle feature flags here ); function App() { return ( ); } ``` -------------------------------- ### Chain buoyDevTools with Persist Middleware Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/zustand.md The `buoyDevTools` middleware can be chained with other Zustand middleware, such as `persist`, to enable debugging for stores that persist their state. ```tsx import { create } from 'zustand'; import { persist } from 'zustand/middleware'; import { buoyDevTools } from '@buoy-gg/zustand'; const useAuthStore = create( buoyDevTools( persist( (set) => ({ user: null, login: (u) => set({ user: u }) }), { name: 'auth-storage' } ), { name: 'authStore' } ) ); ``` -------------------------------- ### Create Custom Debug Borders Tool Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/debug-borders.md Use `createDebugBordersTool` to build a customized version of the debug borders tool. You can specify names, descriptions, colors, and an ID for your custom tool. ```tsx import { createDebugBordersTool } from "@buoy-gg/debug-borders"; const layoutTool = createDebugBordersTool({ name: "LAYOUT", description: "Layout visualizer", offColor: "#9ca3af", bordersColor: "#ec4899", labelsColor: "#8b5cf6", id: "custom-borders", }); ``` -------------------------------- ### Integrate Bench HUD in Web Applications Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/perf-monitor.md Add the PerfMonitorOverlay component to your React web application's tree to display the performance HUD. Use PerfMonitorController.toggle() to show or hide the overlay. ```tsx import { PerfMonitorOverlay, PerfMonitorController } from "@buoy-gg/perf-monitor"; // anywhere in your tree // toggle it PerfMonitorController.toggle(); ``` -------------------------------- ### Redux Middleware Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/redux.md Provides middleware for integrating Buoy's state management capabilities into your Redux store. `buoyReduxMiddleware` is the default, while `createBuoyReduxMiddleware` allows for custom configurations. ```APIDOC ## Redux Middleware ### Description Integrates Buoy's state management into your Redux store. ### Exports - `buoyReduxMiddleware`: The default middleware for Redux integration. - `createBuoyReduxMiddleware`: A factory function to create custom middleware instances with specific configurations. ``` -------------------------------- ### EnvVar Builder API for Defining Requirements Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/env.md The fluent builder API simplifies defining environment variable requirements, including type, expected value, and descriptive documentation. A shorthand is available for simply checking existence. ```tsx envVar("API_KEY") .withType("string") // Set expected type .withValue("sk_test_123") // Or set expected value .withDescription("API Key") // Add documentation .build() // Finalize config // Shorthand for just checking existence envVar("API_KEY").exists() ``` -------------------------------- ### Redux History Adapter Source: https://github.com/buoy-gg/buoy/blob/main/docs/tools/redux.md Utilities for creating custom history adapters for Redux, allowing integration with external systems or custom storage solutions. `reduxHistoryAdapter` and `createReduxHistoryAdapter` facilitate this. ```APIDOC ## Redux History Adapter ### Description Provides tools for creating and managing custom history adapters for Redux state. ### Exports - `reduxHistoryAdapter`: A pre-built history adapter (if applicable). - `createReduxHistoryAdapter`: A factory function to create custom Redux history adapters, enabling integration with various storage or logging mechanisms. ``` -------------------------------- ### Integrate BUOY FloatingDevTools Source: https://github.com/buoy-gg/buoy/blob/main/README.md Conditionally render the FloatingDevTools component based on whether the current user is an internal user. This ensures the tools are only available in development or internal environments. ```tsx <> {/* Your app */} {isInternalUser && } ``` -------------------------------- ### Watch Jotai Atoms Source: https://github.com/buoy-gg/buoy/blob/main/docs/quick-start.md Use the 'watchAtoms' function from '@buoy-gg/jotai' to monitor your Jotai atoms. Call this function once at module scope, passing your store and a named map of atoms. ```tsx import { getDefaultStore } from "jotai"; import { watchAtoms } from "@buoy-gg/jotai"; import { authAtom } from "./atoms/auth"; import { cartAtom } from "./atoms/cart"; watchAtoms(getDefaultStore(), { authAtom, cartAtom, }); ``` -------------------------------- ### Integrate Zustand Stores Source: https://github.com/buoy-gg/buoy/blob/main/docs/quick-start.md Pass your Zustand stores directly to the FloatingDevTools component using the 'zustandStores' prop. This allows the Jotai tool to automatically detect and display your stores. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; import { useAuthStore } from "./stores/auth"; import { useCartStore } from "./stores/cart"; const stores = { authStore: useAuthStore, cartStore: useCartStore, }; return ( ); ``` -------------------------------- ### Register a Basic Custom Tool Source: https://github.com/buoy-gg/buoy/blob/main/docs/custom-tools.md This snippet shows how to register a single custom tool named 'Cache' with a 'CacheDebugger' component. Ensure you import 'FloatingDevTools' from '@buoy-gg/core' and necessary React Native components. ```tsx import { FloatingDevTools } from "@buoy-gg/core"; import { View, Text, Button } from "react-native"; const CacheDebugger = () => { const clearCache = () => { // Your cache clearing logic }; return ( Cache Status: 42 items