{"library":"react-native-launch-arguments","title":"React Native Launch Arguments","description":"The `react-native-launch-arguments` module provides a straightforward API for React Native applications to retrieve arguments passed during their launch. This capability is crucial for scenarios involving end-to-end testing, debugging, and advanced application configuration, allowing external tools like Detox, Appium, Maestro, or native debuggers (Xcode, `xcrun simctl`) to inject parameters directly into the running React Native app. Currently at version 4.1.1, the library typically updates as needed to maintain compatibility with new React Native releases and address platform-specific nuances. Its primary differentiation lies in offering a unified JavaScript interface to access platform-specific argument mechanisms on both iOS and Android, simplifying parameter passing that would otherwise require native bridge development. This facilitates robust testing and development workflows by externalizing configuration. It also ships with TypeScript types, enhancing developer experience for type-safe argument access.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-launch-arguments"],"cli":null},"imports":["import { LaunchArguments } from 'react-native-launch-arguments';","const args = LaunchArguments.value();","interface MyArgs { userId?: string; debugMode?: boolean; }; const args = LaunchArguments.value<MyArgs>();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { LaunchArguments } from 'react-native-launch-arguments';\n\ninterface MyExpectedArgs {\n  authToken?: string;\n  skipAuth?: boolean;\n  environment?: 'dev' | 'staging' | 'prod';\n}\n\n// Retrieve launch arguments with type safety\nconst args = LaunchArguments.value<MyExpectedArgs>();\n\nconsole.log('Application launched with arguments:', args);\n\n// Example of conditional logic based on launch arguments\nif (args.skipAuth) {\n  console.log('Authentication flow skipped as per launch arguments.');\n} else {\n  console.log('Authentication is required.');\n}\n\n// Simulate an API call that might use an auth token from launch args\nconst performAuthenticatedAction = async (token?: string) => {\n  if (token) {\n    console.log(`Using auth token (first 5 chars): ${token.substring(0, 5)}...`);\n    // In a real app, this would be a network request with the token\n    await new Promise(resolve => setTimeout(resolve, 1000));\n    console.log('Authenticated action completed.');\n  } else {\n    console.warn('No authentication token provided via launch arguments.');\n  }\n};\n\nperformAuthenticatedAction(args.authToken);\n\nif (args.environment) {\n  console.log(`Running in ${args.environment} environment.`);\n}","lang":"typescript","description":"Demonstrates how to import and retrieve launch arguments with TypeScript, including defining expected argument types and conditional logic based on received values for common use cases like authentication and environment configuration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}