Registry / serialization / react-native-hardwired

react-native-hardwired

JSON →
library0.10.2jsnpmunverified

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.

npm install react-native-hardwired
INSTALL
IMPORT
SIG · REACT-NATIVE-HARDW
R
react-native-hardwired
serializationjavascriptv0.10.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Hardwired
import { Hardwired } from 'react-native-hardwired'
import Hardwired from 'react-native-hardwired'
This is a named export, not a default export. Using default import will give undefined at runtime.
useHardwired
import { useHardwired } from 'react-native-hardwired'
import { useHardwired as useHardwired } from 'react-native-hardwired'
React hooks are named exports. No alternative pattern is commonly mistaken.
type HardwiredModule
import type { HardwiredModule } from 'react-native-hardwired'
import { HardwiredModule } from 'react-native-hardwired'
Type imports require the 'type' keyword in TypeScript to avoid runtime errors. Importing as value will cause undefined.

Shows creating a Hardwired loader and dynamically importing a precompiled module at runtime.

import { Hardwired } from 'react-native-hardwired'; // Create a hardwired loader instance const loader = new Hardwired({ baseDir: './modules' }); // Dynamically load a precompiled module at runtime async function loadModule() { try { const module = await loader.load('my-dynamic-module'); module.default(); // call default export } catch (error) { console.error('Failed to load module:', error); } } loadModule();
Debug
Known issues
gotchaModules must be precompiled with Babel/TypeScript before bundling. The library does not compile modules for you.
fix
Set up a build step (e.g., Babel) to transpile your dynamic modules into CommonJS before bundling with Metro.
affects: >=0.1.0
gotchaThe baseDir must be a relative path from the Metro bundle's root. Absolute paths are not supported.
fix
Use paths like './modules' or '../src/dynamic' that resolve relative to the project root.
affects: >=0.1.0
breakingIn v0.10.0, the constructor signature changed from (config) to (config: HardwiredConfig). The 'baseDir' property is now required.
fix
Update to new constructor with explicit baseDir: const loader = new Hardwired({ baseDir: './dyn' });
affects: >=0.10.0
deprecatedThe 'load' method's callback parameter is deprecated since v0.9.0. Only promise-based usage is supported.
fix
Use async/await or .then() instead of passing a callback to loader.load().
affects: >=0.9.0
Errors
Common errors & fixes
TypeError: (0 , _reactNativeHardwired.Hardwired) is not a constructor
Using default import instead of named import for Hardwired.
fix
Change 'import Hardwired from ...' to 'import { Hardwired } from ...'
Cannot find module './dyn/myModule'
baseDir is incorrect or module file doesn't exist at the resolved path.
fix
Verify baseDir and module name. Ensure the module file exists and is precompiled.
Module 'myModule' has no exports
The dynamic module was not properly transpiled; missing module.exports.
fix
Add a build step that outputs CommonJS with module.exports.
Upgrade
Version history
0.10.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
react-native-hardwired — npm install react-native-hardwired · libregistry