Webview login with react native
# support-questions
l
Hi i'm curious about whether or not i should create native login or use my existing browser flow (kinda want to just reuse my browser logic), and how that might work regarding session for browser, but header for mobile. Using react native.
n
Hi @Leander , One way to do this would be to first enable JWTs for the session recipe (you can refer to the docs for this). After you complete the sign in flow in the webview and have a session created you can send the JWT to native. Native would then call another API (say
/createsession
) sending the JWT
The API verifies the JWT using the JWKS flow (explained in the docs) and reads the user id from it
And then you can create a new session for that user id which will use headers instead of cookies
l
okey thx, that sounds like it should work 🙂
n
Happy to help, let us know if you run into issues setting it up and we can help out
l
sidestep: is there a clean way to exit webview once login is successfull?
n
By exit you mean close or logout and close?
l
just close the webview and go back to the app
n
Is this going to be an in app webview or launch the browser?
l
im only using the webview for the login/signup process
- the webview is in app
n
You could conditionally render the webview
Copy code
{
    shouldShowWebview && <Webview />
}
And toggle
shouldShowWebview
to false once the login process is complete
That should dismiss it (with the exit animation if im not wrong)
l
i'll test it out! appreciate your help.
n
Happy to help