Lands #39048 with lint fixes. Needed to open a new PR, because GitHub does not allow maintainers to edit organization forks. https://github.com/orgs/community/discussions/5634 Closes #39048 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: Chris Fisher <chris.i.fisher@gmail.com>
2.1 KiB
Executable file
Authsignal Passwordless Login Example
This example shows how to integrate Authsignal with Next.js in order to implement passwordless login using email magic links and server-side redirects.
The login session is managed using cookies. Session data is encrypted using @hapi/iron.
A live version of this example can be found here.
Deploy your own
Deploy the example using Vercel:
How to use
Execute create-next-app
with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example authsignal-passwordless authsignal-passwordless-app
# or
yarn create next-app --example authsignal-passwordless authsignal-passwordless-app
# or
pnpm create next-app --example authsignal-passwordless authsignal-passwordless-app
Deploy it to the cloud with Vercel (Documentation).
Configuration
Log in to the Authsignal Portal and enable email magic links for your tenant.
Copy the .env.local.example file to .env.local:
cp .env.local.example .env.local
Set AUTHSIGNAL_SECRET
as your Authsignal secret key.
The SESSION_TOKEN_SECRET
is used to encrypt the session cookie. Set it to a random string of 32 characters.
Notes
To learn more about Authsignal take a look at the API Documentation.