{"id":26162,"library":"react-native-hardwired","title":"react-native-hardwired","description":"react-native-hardwired v0.10.2 enables runtime dynamic imports of pre-compiled React Native modules, bridging the gap between static bundling and deferred loading. Unlike standard React Native's static require or Metro's lazy loading, this library works with modules already transpiled by Babel/TypeScript, allowing you to load code on demand without ejection or native changes. It ships TypeScript definitions and is released on npm with monthly cadence. Key differentiator: no native modules, works with Hermes, and integrates directly with Metro's require system.","status":"active","version":"0.10.2","language":"javascript","source_language":"en","source_url":"https://github.com/JedrzejMajko/react-native-hardwired","tags":["javascript","typescript"],"install":[{"cmd":"npm install react-native-hardwired","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-hardwired","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-hardwired","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a named export, not a default export. Using default import will give undefined at runtime.","wrong":"import Hardwired from 'react-native-hardwired'","symbol":"Hardwired","correct":"import { Hardwired } from 'react-native-hardwired'"},{"note":"React hooks are named exports. No alternative pattern is commonly mistaken.","wrong":"import { useHardwired as useHardwired } from 'react-native-hardwired'","symbol":"useHardwired","correct":"import { useHardwired } from 'react-native-hardwired'"},{"note":"Type imports require the 'type' keyword in TypeScript to avoid runtime errors. Importing as value will cause undefined.","wrong":"import { HardwiredModule } from 'react-native-hardwired'","symbol":"type HardwiredModule","correct":"import type { HardwiredModule } from 'react-native-hardwired'"}],"quickstart":{"code":"import { Hardwired } from 'react-native-hardwired';\n\n// Create a hardwired loader instance\nconst loader = new Hardwired({ baseDir: './modules' });\n\n// Dynamically load a precompiled module at runtime\nasync function loadModule() {\n  try {\n    const module = await loader.load('my-dynamic-module');\n    module.default(); // call default export\n  } catch (error) {\n    console.error('Failed to load module:', error);\n  }\n}\n\nloadModule();","lang":"typescript","description":"Shows creating a Hardwired loader and dynamically importing a precompiled module at runtime."},"warnings":[{"fix":"Set up a build step (e.g., Babel) to transpile your dynamic modules into CommonJS before bundling with Metro.","message":"Modules must be precompiled with Babel/TypeScript before bundling. The library does not compile modules for you.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use paths like './modules' or '../src/dynamic' that resolve relative to the project root.","message":"The baseDir must be a relative path from the Metro bundle's root. Absolute paths are not supported.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Update to new constructor with explicit baseDir: const loader = new Hardwired({ baseDir: './dyn' });","message":"In v0.10.0, the constructor signature changed from (config) to (config: HardwiredConfig). The 'baseDir' property is now required.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use async/await or .then() instead of passing a callback to loader.load().","message":"The 'load' method's callback parameter is deprecated since v0.9.0. Only promise-based usage is supported.","severity":"deprecated","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change 'import Hardwired from ...' to 'import { Hardwired } from ...'","cause":"Using default import instead of named import for Hardwired.","error":"TypeError: (0 , _reactNativeHardwired.Hardwired) is not a constructor"},{"fix":"Verify baseDir and module name. Ensure the module file exists and is precompiled.","cause":"baseDir is incorrect or module file doesn't exist at the resolved path.","error":"Cannot find module './dyn/myModule'"},{"fix":"Add a build step that outputs CommonJS with module.exports.","cause":"The dynamic module was not properly transpiled; missing module.exports.","error":"Module 'myModule' has no exports"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}