Skip to main content
Version: dev

JavaScript/TypeScript Setup

Fory JavaScript/TypeScript provides xlang Object Serialization, generated models, Node.js gRPC, and browser gRPC-Web clients. Packages are published on npm. The core package works without native acceleration; the optional @apache-fory/hps Node.js fast path requires Node.js 20 or later.

Verify the Toolchain

node --version
npm --version

Object Serialization

Install the core package:

npm install @apache-fory/core@1.5.0

Define a schema and run an xlang round trip:

example.cjs
const { default: Fory, Type } = require("@apache-fory/core");

const userType = Type.struct(
{ typeName: "example.User" },
{
id: Type.int64(),
name: Type.string(),
},
);

const fory = new Fory();
const { serialize, deserialize } = fory.register(userType);

const bytes = serialize({ id: 1n, name: "Alice" });
console.log(deserialize(bytes));
node example.cjs

JavaScript uses xlang mode. Continue with JavaScript/TypeScript Object Serialization, xlang types, configuration, and schema evolution.

For the optional Node.js string fast path, install the matching package version:

npm install @apache-fory/core@1.5.0 @apache-fory/hps@1.5.0

Other Capabilities