docs

About JavaScript Interop

On this page

Ultralight is built on JavaScriptCore-- the same high-performance JavaScript engine used by Safari/WebKit on macOS and iOS.

We expose low-level C bindings to JavaScriptCore so that you can seamlessly integrate your native code with JavaScript running on a page.

📘 C++ Wrapper for JavaScriptCore

We offer a wrapper to simplify usage from C++. See JSHelpers.h in the AppCore API

Using the JavaScriptCore API

To use the JavaScriptCore API in your code, just include <JavaScriptCore/JavaScript.h>:

C
#include <JavaScriptCore/JavaScript.h>

You can browse the API headers for JavaScriptCore by clicking here.

Common API Types

API Type Description
JSContextRef A JavaScript execution context, you will need this to make most calls in JavaScriptCore.
JSValueRef The base type for all JavaScript values (eg, Number, String, Object, Boolean, etc.). This is a garbage-collected type.
JSObjectRef A JavaScript object-- this value is technically typedef'd to the same underlying type as JSValueRef and can be passed anywhere that accepts a JSValueRef. This is a garbage-collected type.
JSStringRef A raw UTF-16 string buffer for passing strings to/from JavaScript.
JSClassDefinition Used to create custom JavaScript objects that wrap native objects.