Render a LynxJS bundle in your React Native application.
Warning
This library was created out of curiosity to explore LynxJS and see how it could be integrated with React Native. It was a weekend project and is purely a proof of concept. While it works, there may be gotchas or edge cases that I haven't encountered. Use at your own discretion. Contributions are welcome, but please be aware that responses to issues and pull requests may be limited.
LynxJS bundles with images won't work with Android. This is because React Native is shipped with fresco:3.6.0
by default, while LynxJS depends on fresco:2.3.0
. Using either version crashes the app. See: lynx-family/lynx#410
yarn add react-native-render-lynx
npx pod-install
Expo Prebuild
In yourapp.config.js
:
{
// ...
plugins: [
// ...
+ 'react-native-render-lynx',
],
// ...
}
iOS Template Changes
In yourios/Podfile
:
post_install do |installer|
# ...
+ installer.pods_project.targets.each do |target|
+ if target.name == 'Lynx'
+ target.build_configurations.each do |config|
+ config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'gnu++17'
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
+ end
+ end
+ end
end
💡 You need to re-run
npx pod-install
.
Android Template Changes
In yourandroid/app/src/main/java//MainApplication.kt
:
+ import com.renderlynx.LynxInitializer
class MainApplication : Application(), ReactApplication {
// ...
override fun onCreate() {
super.onCreate()
+ val initializer = LynxInitializer()
+ initializer.initLynxService(applicationContext)
+ initializer.initLynxEnv(this)
SoLoader.init(this, OpenSourceMergedSoMapping)
// ...
}
// ...
}
import { View, StyleSheet, Platform } from 'react-native';
import RenderLynxView from 'react-native-render-lynx';
export default function App() {
// const bundleUrl = 'http://192.168.68.50:3001/main.lynx.bundle?fullscreen=true';
const bundleUrl = Platform.select({ android: 'noimage.lynx.bundle', default: 'main.lynx.bundle' });
return (
<View style={styles.container}>
<RenderLynxView style={styles.viewStyle} bundleUrl={bundleUrl} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 50,
},
viewStyle: {
height: 700,
width: 300,
marginTop: 32,
},
});
Run yarn dev
, npm run dev
, or rspeedy dev
in your LynxJS project and copy the bundle URL.
<RenderLynxView bundleUrl='http://192.168.68.50:3001/main.lynx.bundle?fullscreen=true' />
{
// ...
plugins: [
// ...
[
'react-native-render-lynx',
{
bundlePath: './src/main.lynx.bundle',
},
],
],
// ...
}
This will use ./src/main.lynx.bundle
on both iOS and Android. If you want to override you can do:
{
bundlePath: './src/main.lynx.bundle',
android: {
bundlePath: './src/noimage.lynx.bundle',
},
},
This will use ./src/main.lynx.bundle
on iOS and ./src/noimage.lynx.bundle
on Android.
- Open your project on Xcode.
- In the target settings of your project, select the target.
- Select the Build Phases tab.
- In the Copy Bundle Resources section, click the ✚ icon, click the Add Other... button, and select your bundle file.
Put your bundle file main.lynx.bundle
in android/app/src/main/assets
directory.
💡 Create the directory if it does not exist.
You can start creating LynxJS bundles by following the official documentation: https://lynxjs.org/guide/start/quick-start.html
See CHANGELOGS.md
Copyright © 2025 David Angulo, released under the MIT license, see LICENSE.
Made with create-react-native-library