Step 6: Setup Sendgrid

Setting Up SendGrid and Configuring Your API Key

  1. Create a SendGrid Account

Sendgrid offers a free account with a sending limit of 100 emails per day. If you need a higher limit, sign up for a premium account.

  1. Generate Your API Key
  • Once logged in, go to the Settings tab on the left-hand sidebar.
  • Click on API Keys.
  • Click Create API Key and provide a name for your key (e.g., "MyProject API Key").
  • Choose the appropriate permissions for your key (Full Access is recommended for most use cases).
  • Click Create & View. Your API key will be displayed—copy it immediately as you won't be able to view it again.
  1. Approve a "From" Email Address
  • Navigate to the Sender Authentication section in the Settings menu.
  • Click Verify a Single Sender.
  • Fill out the form with your email address and other required details.
  • Click Create.
  • SendGrid will send a verification email to the address you provided. Open that email and click on the verification link to approve the address.
  1. Add Your API Key and to the .env.local File
  • Open your project's root directory.
  • Locate the .env.local file or create one if it doesn't exist.
  • Add your SendGrid API key to the .env.local file as follows:
NEXT_PUBLIC_SENDGRID_API_KEY="your_sendgrid_api_key_here"
  1. Use Your Verified Email Address

Set the verified email address as the value of the NEXT_PUBLIC_SENDGRID_FROM_EMAIL variable located in the .env.local file.

NEXT_PUBLIC_SENDGRID_FROM_EMAIL="your_sendgrid_from_email_address_here"