This tutorial will teach you how to use Magic Link to onboard users to your DApp with just an email. You will first learn how to authenticate users in to your DApp. After authenticating, you will have the user’s login info and learn how to send a test transaction as well.
To check out a working example, go here.
Getting Started
We will be using the Magic Link Flow documentation to guide you through this process.
Authenticate using Magic Link
The first part of this tutorial will be how to authenticate users into your DApp using Magic Link.
We will be using React for this tutorial, however you can easily use Svelte or any other framework as well. To create a fresh DApp, open up a terminal and paste npx create-react-app magic-flow-tutorial
.
Navigate to your magic-flow-tutorial
directory in terminal and follow the steps below.
1. Install Dependencies
2. Create a New Magic Instance
To create a Magic instance, you will need an API key from their platform. Go to https://dashboard.magic.link/login, create an account, create a new project, and select “Flow (testnet)” for your network. You will then be redirected to your API Keys.
You will see your “Publishable API Key” here:

Inside your DApp, open up the App.js
file and replace it with the following code:
Make sure to replace “APY_KEY” with your own. It should look something like pk_live_A0518BB95A143BFB
.
3. Configure FCL
Now we need to actually connect to Flow testnet in order to log in. To do that, add the following code to your App.js
file:
4. Authenticate
Now we can have users authenticate into our DApp. Let’s modify our App.js
file a little to include a place for users to type in their email and log in.
Try to click the “Login” button and see if it prompts you to log in.
5. Getting Account Data (address & email) + Logging Out
Now that the user has authenticated in, we want to display a welcome message with their flow address. And allow them to log out.
6. Viewing Your Wallet
We can also add a button so a user can view information about their wallet.
Add the following button below the logout button:
7. Sending Test Transaction
Now that we have completed the authentication user flow, lets try to send a transaction with the user’s account once they are logged in.
Let’s write a sendTransaction
function that simply logs the signer’s address.
We can add this to our App.js
file, along with a button that the user can click to run the test transction:
We’re all done! Open up the developer console to see if it works.
Next Steps
To check out a working example, go here.
Till next time ~ Jacob Tucker