To create a better-auth secret key, run the following command:
npx @better-auth/cli@latest secret
This will generate a secret key that you can use in your .env file.
BETTER_AUTH_SECRET=YOUR_SECRET_KEY
Also update the BETTER_AUTH_URL in your .env file to match your domain. Replace http://localhost:3000 with your domain if you are deploying to production.
BETTER_AUTH_URL=http://localhost:3000 #Base URL of your app
If you want to include some additional Better-Auth plugins, you have to run the following command:
npx launch-express@latest generate-schema

Google OAuth

To enable Google OAuth, you need to create a new project in the Google Developer Console.
  1. Go to the Google Developer Console.
  2. Create a new project.
  3. Go to the OAuth consent screen and fill in the required fields.
  4. Go to the Credentials tab and create a new OAuth client ID.
  5. Add the client ID and client secret to your .env file.
GOOGLE_CLIENT_ID=YOUR_GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET=YOUR_GOOGLE_CLIENT_SECRET
To enable Magic Link, you need a email provider. We are using Resend in this Starter-Kit.
  1. Go to Resend and create an account.
  2. Go to the Settings tab and copy the API key.
  3. Add the API key to your .env file.
RESEND_API_KEY=YOUR_RESEND_API
You also need to add your domain to the Resend Domains. Now for the functionality to work, you need to add the following code to your config/config.ts file and set also the additionalAuthMethod to magic-link. You get the infos from the Resend SMTP page. You can also change this to your own SMTP provider.
...
email: {
  server: {
    host: 'smtp.resend.com',
    port: 587,
    auth: {
      user: // Your Resend Username,
      pass: // Your Resend API key,
    },
  },
  from: // Your sending email address,
},
...