# Global Shared Example

> See how to use g.shared to share data across APIs, pre/post-hooks, and custom code in API Maker—enable seamless data flow.

Source: https://docs.apimaker.dev/v1/examples/shared/globalShared.html

### Shared data globally

`g.shared` is used to share data between post-hooks, pre-hooks, code, and APIs.

- If the user set a shared variable from the one API response.
```ts
g.shared.outPreApi = g.res.output;
```

- User can get that shared variables value in another API.
```ts
g.req.body = g.shared.outPreApi;
```

## Related

- [The global object g](https://docs.apimaker.dev/v1/docs/pre-defined-terms/global-object-g.html) · [Custom APIs](https://docs.apimaker.dev/v1/docs/apis-all/custom-apis/user-created-custom-api.html)
