This is an interface to provide a <Store>
with authentication data.
StoreIdentity
entityRecord
EntityRecord
client
Client
blobUrlBuilder
BlobUrlBuilder
The <Store>
component does not require a specific authentication mechanism and will accept any StoreIdentity
regardless of how it’s procured.
In this example, we read the identity from a variable injected on window
by an HTML script from the server that generated the page instead of relying on useAuthentication
.
import {Client} from "@baqhub/sdk";
import {Store} from "./baq/store.js";
const serverData = JSON.parse(window.serverData);
const client = Client.authenticated({
entityRecord: serverData.entityRecord,
appRecord: serverData.appRecord,
credentialsRecord: serverData.credentialsRecord,
serverPublicKey: serverData.publicKey,
});
const blobUrlBuilder = await client.buildBlobUrlBuilderAsync();
const identity = {
entityRecord: serverData.entityRecord,
client,
blobUrlBuilder,
};
function App() {
return (
<Store identity={identity}>
<Home /> {/* Rest of the app */}
</Store>
);
}