Browser APIs


You can use browser APIs in genericjs code via the client namespace.


clientlib.h declares browser APIs and can be included with:

#include <cheerp/clientlib.h>


client.h contains helpers like the SAFE_INLINE macro and utilities under the cheerp namespace.

#include <cheerp/client.h>

Promises and cheerp/coroutine.h

Promises can be awaited using coroutines.

For example:

#include <cheerp/coroutine.h>
#include <cheerp/client.h>
using namespace client;
Promise<String*>* randomUUID() {
Response* response = co_await *fetch("");
Object* json = (co_await *response->Body::json())->cast();
co_return (*json)["uuid"]->cast();

Any coroutine can be wrapped into a Promise using the following snippet:

Promise<Object*>* wrapper() {
co_return co_await coroutine();

Complex types

client.h also provides complex types like _Any, _Union, and _Function.


OpenGL ES is also supported with a different header.

Was this page helpful?
Suggest changes