From 5931f5abc5a7790af110404a3b89e989e168b514 Mon Sep 17 00:00:00 2001 From: horsefacts <109845214+horsefacts@users.noreply.github.com> Date: Fri, 26 Jan 2024 15:36:12 -0700 Subject: [PATCH] fix: check for window.location (#124) --- .changeset/angry-hornets-divide.md | 5 +++++ .../src/components/AuthKitProvider/AuthKitProvider.tsx | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/angry-hornets-divide.md diff --git a/.changeset/angry-hornets-divide.md b/.changeset/angry-hornets-divide.md new file mode 100644 index 0000000..992e454 --- /dev/null +++ b/.changeset/angry-hornets-divide.md @@ -0,0 +1,5 @@ +--- +"@farcaster/auth-kit": patch +--- + +fix: check window.location for RN compatibility diff --git a/packages/auth-kit/src/components/AuthKitProvider/AuthKitProvider.tsx b/packages/auth-kit/src/components/AuthKitProvider/AuthKitProvider.tsx index 1ef6e52..5932aec 100644 --- a/packages/auth-kit/src/components/AuthKitProvider/AuthKitProvider.tsx +++ b/packages/auth-kit/src/components/AuthKitProvider/AuthKitProvider.tsx @@ -35,11 +35,15 @@ export interface AuthKitContextValues { onSignOut: () => void; } +const domainDefaults = window.location ? { + domain: window.location.host, + siweUri: window.location.href +} : {}; + const configDefaults = { relay: "https://relay.farcaster.xyz", version: "v1", - domain: window.location.host, - siweUri: window.location.href + ...domainDefaults }; export const AuthKitContext = createContext({