- Expo
- Vanilla
For an in-depth guide to deeplinking with Expo, refer to the Expo docs.Below is a summary of the steps required:
Create the base URL
Use
Linking.createUrl() from the expo-linking package to create the base URL you will pass into the login_magic_link_url and signup_magic_link_url params for calls to initiate magic links. Linking.createUrl() will return exp://127.0.0.1:19000 for Expo apps in development, exp://exp.host/@community/with-webbrowser-redirect for apps published in Expo Go, and myapp:// for published apps. This way, you can pass the value returned by Linking.createUrl() into stytchClient.magiclinks.email.loginOrCreate and it will work for both development and production cases. Your initiate call will look something like this:Handle the deep link
In the above use case, when a user clicks the magic link in their email, they will be redirected to the route you passed in, with a token attached as a query parameter. You will then use the token from the query param to authenticate your user with
stytchClient.magicLinks.authenticate(token, {session_duration_minutes: 60}); For detailed information on handling deep links into your Expo app, check out the Expo docs here. An example using react-navigation could look like this: