1

I am using Supabase for Auth with React Native and using React Navigation. When the user requests for password reset I set a redirect URL myApp://updatepassword. This link comes back with the link in the email but only always opens the initialRoute/first route on the navigation stack. I am using React Navigation. Note: myApp://updatepassword works as expected when I run it in the browser on the device or simulator. Is it possible Supabase only takes the first part of my route? That is myApp://?

I tried to set the redirect directly on the Supabase console as well as in the callback directly. I always get the right link (https://...supabase.co/auth/v1/verify?token=&type=recovery&redirect_to=myApp://updatepassword/) but still matches only the initial or first route on the stack. I saw an issue that says it needs the trailing slash but still doesn't work. Any ideas why would be appreciated.

Cortehz
  • 21
  • 5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 23 '22 at 12:11
  • I recommend watching [this playlist](https://www.youtube.com/playlist?list=PL5S4mPUpp4OvEgxBhoVxXb5YS1ZAZih2l) to see how the DevRel team implement such features. – Mansueli Dec 23 '22 at 14:05

1 Answers1

0

In case anybody runs into something similar. Turns out it's as a result of the # URL fragment in Supabase and React Navigation does not work with #. Using the getStateFromPath we can get the URL and replace # to access the URL properly with React Navigation. Like so:

import { getStateFromPath } from '@react-navigation/native';

const linking: LinkingOptions<RootStackParamList> = {
  prefixes: [prefix],
  config: {
    screens: {
      updatepassword: 'updatepassword'
    }
  },
  getStateFromPath: (path, options) => {
    const accessiblePath = path.replace("#", "?");

    return getStateFromPath(accessiblePath, options);
  },
};

This was answered here by @suchardao https://github.com/supabase/supabase/discussion/10754#discussioncomment-4401396.

Cortehz
  • 21
  • 5