# Astro Resume Utilities for serializing data from server for use in the client. 1. `Serialize` - Astro component that takes `id` and `data` 1. `deserialize(id: string)` - a function for use in the client that takes an `id` string and returns the `data` object ## Installation & Examples ### Install via npm On your [Astro](https://astro.build) project: ``` npm i @ayco/astro-resume ``` ### Usage Serializing and deserializing basic primitive data ```astro --- import Serialize from "@ayco/astro-resume"; const data = { hello: 'world', } --- ``` ### Type Safety You can define a type for the data and use it in the client script. ```astro --- import Serialize from "@ayco/astro-resume"; const data = { hello: 'world', isOkay: true } // define the type of data to be serialized export type Data = typeof data; --- ``` ### Passing all Astro.props to client If you need to make all the component props to the client script: ```astro --- import Serialize from "@ayco/astro-resume"; export interface Props { hello: string; isOkay: boolean; } --- ``` ### Using a custom serializer and parser You can bring your own serializer/parser. For serializing data that `JSON.parse` cannot parse (e.g., Date or BigInt), here's an example of using Rich Harris' `devalue` ```astro --- import {stringify} from 'devalue'; import Serialize from "../Serialize.astro"; const data = { name: 'John Doe', isOkay: true, mood: null, now: new Date(), age: BigInt('3218378192378') } export type Data = typeof data; --- ``` ## About This is a quick and easy pattern to embed serialized information into your HTML and make it available in the client-side script with type safety. The `Serialize` component will write the data as JSON wrapped in a `