To link to your development build or standalone app, you need to specify a custom URL scheme for your app. You can register a scheme in your app config (app.json, app.config.js) by adding a string under the scheme
key:
_10 "scheme": "com.supabase"
In your project's auth settings add the redirect URL, e.g. com.supabase://**
.
Finally, implement the OAuth and linking handlers. See the supabase-js reference for instructions on initializing the supabase-js client in React Native.
_71import { Button } from "react-native";
_71import { makeRedirectUri } from "expo-auth-session";
_71import * as QueryParams from "expo-auth-session/build/QueryParams";
_71import * as WebBrowser from "expo-web-browser";
_71import * as Linking from "expo-linking";
_71import { supabase } from "app/utils/supabase";
_71WebBrowser.maybeCompleteAuthSession(); // required for web only
_71const redirectTo = makeRedirectUri();
_71const createSessionFromUrl = async (url: string) => {
_71 const { params, errorCode } = QueryParams.getQueryParams(url);
_71 if (errorCode) throw new Error(errorCode);
_71 const { access_token, refresh_token } = params;
_71 if (!access_token) return;
_71 const { data, error } = await supabase.auth.setSession({
_71 if (error) throw error;
_71const performOAuth = async () => {
_71 const { data, error } = await supabase.auth.signInWithOAuth({
_71 skipBrowserRedirect: true,
_71 if (error) throw error;
_71 const res = await WebBrowser.openAuthSessionAsync(
_71 if (res.type === "success") {
_71 await createSessionFromUrl(url);
_71const sendMagicLink = async () => {
_71 const { error } = await supabase.auth.signInWithOtp({
_71 email: "example@email.com",
_71 emailRedirectTo: redirectTo,
_71 if (error) throw error;
_71export default function Auth() {
_71 // Handle linking into app from email app.
_71 const url = Linking.useURL();
_71 if (url) createSessionFromUrl(url);
_71 <Button onPress={performOAuth} title="Sign in with Github" />
_71 <Button onPress={sendMagicLink} title="Send Magic Link" />
For the best user experience it is recommended to use universal links which require a more elaborate setup. You can find the detailed setup instructions in the Expo docs.