[SOLVED] Redirect on sign in with MetaMask

Hi Moralis Community,

Is it possible to change the route ("/") where you go to upon successful sign in via the Moralis Authenticate via MetaMask function?

I know you can customize the sign in message for example, but is it possible to go to a specific route (i.e. “/hello” or “/contact” or “/welcome”) after a user has successfully authenticated via MetaMask?

Thanks!

maybe you can do the redirection in the next line after authenticate, something like:

        user = await Moralis.User.current();
        if (!user) {
            user = await Moralis.authenticate({signingMessage: "with redirect"});
            // redirect here
        }

2 Likes

Thanks @cryptokid!! Yes this works :blush: Got it all figured out…mainly on the user not logged-in state. This works perfectly w/ NEXTjs!

1 Like

Hi guys,

I’m new in web development and I have a question.
Can someone please gime me an example what to add on the comment
// redirect here

there could be various ways to do a redirection to another page, you can try to see what works for you

Can you gime an example?

you can try to search on google how to do a redirect in your specific framework

I’m using Vanilla JS

ok, you can try to search on google: how to redirect in javascript to a new page

Ok, thank you so much for your advice and time