Login Views Tutorial
In this guide we will set up a simple example of programmatically changing views based on where the user is coming from.
We’re going to be referring a lot to the views type, found here.
Determine where the user is coming from
In our example, we will show a different signup/login experience to users coming from a specific URL. We will use the useLocation
hook from react-router-dom
to get the current URL.
If the user is coming from /landing-page/facebook, we will show only a Facebook button which gives you an embedded wallet. If you are coming from /landing-page/web3, we will show the default signup/login experience.
In the below code we are using the useState
hook to create a state variable called source
and a setter function called setSource
. We are then using the useEffect
hook to set the source to the current location.
Declare the views
Views are passed in via the overrides key on the settings prop of DynamicContextProvider
The view object itself is of a specific type and you can review the type on the reference.
In our case, we want two different views, one for Facebook and one for Web3. We will use the facebook
and web3
views.
Setting types to state
We want somewhere to store our view overrides. We will use the useState
hook to create a state variable called viewOverrides
and a setter function called setViewOverrides
.
Setting the view overrides
We will use the useEffect
hook to set the view overrides to the correct view based on the source.
Adding to the DynamicContextProvider
We can now pass the viewOverrides to the DynamicContextProvider
.
Putting it all together
Adding embedded wallets
That’s it! To make sure our facebook group also get an embedded wallet,follow this guide
Was this page helpful?