hermes
hermes copied to clipboard
Use hermes on mobile native code without react native
Problem
I'm looking into executing JS code on a native app (iOS/Android non-react native), and exploring using Hermes to optimize it. Is there any documentation on this?
The goal is to have a JS code snippet, call a function there with certain params and get an output back on the native code.
For instance on iOS by replacing the usage of JavaScriptCore
:
let context = JSContext()
let myFn = context?.evaluateScript(myJsScript)
let result = myFn.call(withArguments: ["something here"]);
The short answer is that yes, this is possible and generally speaking easy. However there isn't good documentation for this use case since almost all of our user-facing documentation is RN-specific.
We have had similar question asked before:
- https://github.com/facebook/hermes/issues/43
- https://github.com/facebook/hermes/issues/326
We would welcome a community contribution with documentation about it :-)
@tmikov thank you for the links. I'm evaluating our options, and once I get back to this I'll dig a bit in there and add some documentation if we manage to achieve our objectives.
@GlisboaDev Have you made any progress or have a working example yet?
@benjaminbarbe there are working examples here: https://github.com/tmikov/hermes-jsi-demos