https://supabase.com/ logo
<@107176742342402048> (sorry to ping you, but I th...
# help
n
@silentworks (sorry to ping you, but I think you mostly manage the auth-helpers repo?) I wanted to poke around and maybe contribute to the library to improve the next.js integration. One question I had was, is it possible to use the SSR version of the access token to establish a connection with supabase subscriptions? What I noticed was this: 1.
getServerSideProps
has a token and fetches the user, with a certain token 2. Calling
supabaseClient.from().on()
does not work unless I do
useUser()
and wait for that user to resolve which uses another token. I was hoping to look into the
<UserProvider user={}
prop to see if I can maybe pass in the user and token and fix #2 above
n
Hello @nahtnam! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
s
Should be the same accessToken being used in both instances
n
Copy code
export function HomePage(
  props: InferGetServerSidePropsType<typeof getServerSideProps>,
) {
  const { initialUser } = props;

  if (initialUser)
    return (
      <UserProvider user={initialUser} supabaseClient={supabaseClient}>
        <AppPage />
      </UserProvider>
    );

  return <LandingPage />;
}

export async function getServerSideProps(context: GetServerSidePropsContext) {
  const { user } = await getUser(context);

  return { props: { initialUser: user } };
}
Tried doing this
Problem is the subscription (which can only be done on client side) is not working. I have to add an additional line:
Copy code
const {user: clientUser } = useUser();

useEffect(() => {
  if (!clientUser) return
  .... subscribe here ... 
}, [clientUser])
The bearer tokens are different between the first render and the renders after the
useUser()
resolves
2 Views