SwiftUI Login/Signup Redirect Page

Hello Stytch, I am able to Login/Signup a user and authenticate them after following the Swift Stytch Example App, but I am wondering how to direct the user to a different screen based upon their account status. Basically the user will open the app to the Stytch Magic-Link Email box, after they press submit, I want to direct them to the main app home page if they are an existing user, and if they are brand new, I want to direct them to a Sign Up view that lets them finish creating an account that will then be uploaded to MongoDB Realm (authenticated via Stytch JWT). Has anyone had to solve this problem before?

Hey Liam – thanks for posting!

When you call our Magic Links loginOrCreate function, you can provide two different optional parameters – one called signupMagicLinkUrl and one called loginMagicLinkUrl. Those values will determine which link new users are sent and which link existing users are sent, respectively. If those parameters are not set, we’ll use the default signup and login URLs that you have configured on the Redirect URLs page in the Stytch Dashboard.

Once the user is sent either a signup URL or login URL and clicks the link in the email, your application can display your signup view for users sent to the signup URL and your main app homepage for users sent to the login URL.

I hope that helps! Let me know if you have any questions about this, and I’ll be happy to follow up.