Skip to content

Commit 8db5ee8

Browse files
committed
fix SSR build
1 parent 0e9cb5d commit 8db5ee8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,22 @@ export type HypergraphAppProviderProps = Readonly<{
221221
children: ReactNode;
222222
mapping: Mapping;
223223
}>;
224+
225+
const mockStorage = {
226+
getItem(_key: string) {
227+
return null;
228+
},
229+
setItem(_key: string, _value: string) {},
230+
removeItem(_key: string) {},
231+
};
232+
224233
// 1) a) Get session token from local storage, or
225234
// b) Auth with the sync server
226235
// 2) a)Try to get identity from the sync server, or
227236
// b) If identity is not found, create a new identity
228237
// (and store it in the sync server)
229238
export function HypergraphAppProvider({
230-
storage = localStorage,
239+
storage = typeof window !== 'undefined' ? localStorage : mockStorage,
231240
syncServerUri = 'https://syncserver.hypergraph.thegraph.com',
232241
chainId = Connect.GEO_TESTNET.id,
233242
children,

0 commit comments

Comments
 (0)