Skip to content

kjmczk/nextjs-faunadb-magiclink-typescript

Repository files navigation

NextJS FaunaDB MagicLink TypeScript

This is a project that integrates Magic passwordless authentication into an app built with Next.js, FaunaDB, TailwindCSS, and TypeScript.

Running locally

  1. Clone this project:
git clone https://github.com/kjmczk/nextjs-faunadb-magiclink-typescript.git
  1. Change into the directory:
cd nextjs-faunadb-magiclink-typescript
  1. Install the dependencies:
yarn install
  1. Login to the Magic Dashboard and get the keys of your app:

Magic Keys

  1. Login to the Fauna Dashboard and create a new database:

New Database

  1. Go to the Fauna Shell and run the FQL functions in the fauna directory in the order of Collections, Indexes, Functions, Roles, Keys:

Fauna Shell

After creating the key, copy its secret.

  1. Copy the .env.local.example file to .env.local:
cp .env.local.example .env.local

Then set each variable in .env.local:

  • NEXT_PUBLIC_MAGIC_PUBLISHABLE_KEY should look like pk_live_91...
  • MAGIC_SECRET_KEY should look like sk_live_B8...
  • FAUNA_GUEST_SECRET should look like fnAELQh0NC...
  • ENCRYPTION_SECRET should be a string with at least 32 characters
  1. Run the server:
yarn dev