An open API service indexing awesome lists of open source software.

https://github.com/usebarekey/react

React bindings for Barekey
https://github.com/usebarekey/react

Last synced: 10 days ago
JSON representation

React bindings for Barekey

Awesome Lists containing this project

README

          

# @barekey/react

React bindings for Barekey with Suspense-friendly `useBarekey()` reads and a dev-only browser leak guard for private variables.

```tsx
import { PublicBarekeyClient } from "@barekey/sdk/public";
import { BarekeyProvider, useBarekey } from "@barekey/react";
import barekeyConfig from "../barekey.json" with { type: "json" };

const barekeyClient = new PublicBarekeyClient({
json: barekeyConfig,
});

function App() {
const env = useBarekey();
return

{env.get("PUBLIC_THEME")}
;
}

export function Root() {
return (



);
}
```

You can also pass a client directly when you want to read Barekey values before any provider exists:

```tsx
import { PublicBarekeyClient } from "@barekey/sdk/public";
import { useBarekey } from "@barekey/react";
import barekeyConfig from "../barekey.json" with { type: "json" };

function Bootstrap() {
const env = useBarekey(new PublicBarekeyClient({ json: barekeyConfig }));
return

{env.get("PUBLIC_THEME")}
;
}
```