{"library":"reactotron-core-client","title":"Reactotron Core Client","description":"Reactotron is a powerful open-source desktop application (macOS, Windows, Linux) by Infinite Red for debugging React and React Native applications. `reactotron-core-client` (current version 2.9.9) serves as the foundational communication layer, enabling client-side applications (like `reactotron-react-native` or `reactotron-react-js`) to connect and exchange data with the Reactotron desktop server. This package provides the `createClient` function, which initializes the connection via WebSockets and handles command dispatching and receipt. It is designed to be pluggable, allowing for extensive customization and feature additions through a plugin architecture. Reactotron generally follows a frequent release cadence across its monorepo, with core components like `reactotron-core-client` receiving updates as needed to support new features or fix issues. Key differentiators include its rich plugin ecosystem (for Redux, MobX, networking, async storage, global errors, custom commands), real-time state inspection, API request/response monitoring, and the ability to perform quick performance benchmarks. It distinguishes itself from other debuggers by communicating over TCP ports and offering features like image overlays for UI development.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install reactotron-core-client"],"cli":null},"imports":["import { createClient } from 'reactotron-core-client';","import { Reactotron } from 'reactotron-core-client';","import { Plugin } from 'reactotron-core-client';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createClient } from 'reactotron-core-client';\n\n// In a Node.js environment, you might need a WebSocket polyfill or 'ws' package.\n// For browser environments, window.WebSocket is used by default.\n// const WebSocket = require('ws'); // If using in Node.js without a global WebSocket\n\nconst client = createClient({\n  // Required: provide a WebSocket implementation, e.g., for Node.js\n  createSocket: (path) => new WebSocket(path),\n  host: process.env.REACTOTRON_HOST ?? 'localhost',\n  port: parseInt(process.env.REACTOTRON_PORT ?? '9090', 10),\n  name: 'My Generic Client',\n  onConnect: () => {\n    console.log('Reactotron client connected!');\n  },\n  onDisconnect: () => {\n    console.log('Reactotron client disconnected!');\n  },\n  onCommand: ({ type, payload }) => {\n    console.log(`Received command: ${type}`, payload);\n  },\n});\n\nclient.connect();\n\n// Send a simple log message\nclient.send('log', { level: 'info', message: 'Hello from Reactotron client!' });\n\n// Send an object log message\nclient.send('log', {\n  level: 'debug',\n  message: {\n    component: 'App',\n    status: 'initialized',\n    user: { id: 1, name: 'Test User' },\n  },\n});\n\n// Example of sending an error\ntry {\n  throw new Error('Something went wrong!');\n} catch (error: any) {\n  client.send('log', { level: 'error', message: error.message, stack: error.stack });\n}\n\n// You can also expose the client globally for easier access in development\n// (global as any).tron = client;\n\nconsole.log('Reactotron client initialized. Check your Reactotron desktop app.');","lang":"typescript","description":"This quickstart demonstrates how to initialize `reactotron-core-client`, connect to the Reactotron desktop app, and send basic log and error messages using the `send` method. It highlights the `createClient` function with essential configuration options like `host`, `port`, and lifecycle callbacks.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}