diff --git a/README.md b/README.md index 979c701..8a5b2fc 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,51 @@ export interface Props { ``` +## Serialize server data once, access everywhere + +If you have shared data that needs to be initialized from the server and accessed in several places on the client-side, you can use `Serialize` once and `deserialize` in any number of Astro components as long as they are in the same page. + +In this example, an appConfig object is built and serialized in index.astro and accessed in child Astro components. + +In index.astro: +```astro +import Serialize from "@ayco/astro-resume"; + +const appConfig = { + someClientSideKey: '1234hello', +} +export type AppConfig = typeof appConfig; +--- + + + +``` + +In Child.astro: +```astro +

I'm a child. I have access to the appConfig in index!

+ + +``` + +In GrandChild.astro: +```astro +

I'm a grand child. I also have access to the appConfig in index!

+ +``` + ## Using a custom serializer and parser You can bring your own custom serializer/parser if you want to opt for more complex data handling.