Skip to content

Quickstart

Getting started with @nhtio/web-serialization is quick and easy. Just follow the steps below and you'll be up and running in no time.

Installation

You can install @nhtio/web-serialization directly from your preferred package manager

sh
npm i @nhtio/web-serialization
sh
pnpm add @nhtio/web-serialization
sh
yarn add @nhtio/web-serialization

Using

This library exports 4 main methods:

typescript
import {
    canSerialize,
    confirm,
    deserialize,
    serialize
} from '@nhtio/web-serialization'

To serialize a value, simply use the serialize method

typescript
const serialized = serialize(...);

To return the value to its initial state, use the deserialize method

typescript
const initial = deserialize(serialized);

Supported data types

This library add support for serialization / deserialization of the standard types supported out of the box by @ungap/structured-clone

Additionally, this library also supports serialization/deserialization of the following types: