How to add Magic Link to a Gatsby site
npx make-magic --template gatsby
Hi 👋, in this guide you'll be learning how to add passwordless login to a Gatsby site using Magic Link.
To start, run the following CLI command in your terminal. The
make-magic NPM package is the quickest way to bootstrap a Magic project from a list of pre-built templates.
01npx make-magic --template gatsby
After a few seconds, you will be prompted for a project name, this will also be the name of the folder that will be created for this project.
After putting in a project name, you will be prompted for your Magic Publishable API Key, which enables user authentication with Magic.
To get your publishable API key, you'll need to sign up to Magic Dashboard. Once you've signed up, an app will be created upon your first login (you'll be able to create new apps later).
You'll now be able to see your Publishable API Key - copy and paste the key into your CLI prompt.
After hitting Enter, you'll be asked to select whether you’d like to use npm / yarn as the NPM client for your project.
After selecting your NPM client, the Gatsby server will automatically start, and your application will be running on http://localhost:8000.
In this example app, you'll be prompted to sign up for a new account using an email address or login to an existing one. The authentication process is secured by Magic.
After clicking on your magic link email, you'll be successfully logged in, and redirected to the profile page that displays your email and public address.