Prerequisites
Before deploying to Netlify, ensure you have:- A Netlify account (sign up for free)
- Your code in a Git repository (GitHub, GitLab, or Bitbucket)
- Your environment variables ready
Configuration
The project includes anetlify.toml configuration file that defines the build settings:
Configuration Details
- Build Command:
next buildcompiles your Next.js application for production - Publish Directory:
.nextcontains the built application - Next.js Plugin:
@netlify/plugin-nextjsenables Next.js features like ISR, SSR, and API routes
Deployment Steps
Connect Your Repository
- Log in to Netlify
- Click Add new site > Import an existing project
- Select your Git provider (GitHub, GitLab, or Bitbucket)
- Authorize Netlify to access your repositories
- Select your Product Builders repository
Configure Build Settings
Netlify will automatically detect your
netlify.toml configuration. Verify the settings:- Build command:
next build - Publish directory:
.next - Production branch:
main(or your default branch)
netlify.toml, so no manual input is needed.Add Environment Variables
Before deploying, add your environment variables:
- In your site settings, go to Site settings > Environment variables
- Click Add a variable
- Add
RESEND_API_KEYwith your Resend API key value
Continuous Deployment
Netlify automatically deploys your site when you push changes to your Git repository:- Production deploys: Triggered by commits to your main branch
- Deploy previews: Automatically created for pull requests
- Branch deploys: Optional deployment of specific branches
Deploy Previews
Every pull request gets its own unique URL for testing changes before merging:- Create a pull request in your repository
- Netlify automatically builds and deploys a preview
- Review the preview URL in the PR comments
- Merge when ready - production automatically updates
Custom Domain
To use your own domain:Configure DNS
Update your domain’s DNS settings:
- Add Netlify’s nameservers, or
- Add a CNAME record pointing to your Netlify subdomain
Environment Variables
Manage environment variables in the Netlify dashboard:- Go to Site settings > Environment variables
- Add, edit, or delete variables
- Trigger a new deploy to apply changes
Monitoring and Logs
Build Logs
View build logs for each deployment:- Go to Deploys in your site dashboard
- Click on any deployment
- View the build log output
Function Logs
Next.js API routes run as Netlify Functions. View their logs:- Go to Functions in your site dashboard
- Click on a function to see invocation logs
- Monitor errors and performance
Troubleshooting
Build Failures
If your build fails:- Check the build logs in the Netlify dashboard
- Verify all dependencies are in
package.json - Ensure Node.js version compatibility (set in
package.jsonif needed) - Check that environment variables are configured
Next.js Features Not Working
If ISR, SSR, or API routes aren’t working:- Verify
@netlify/plugin-nextjsis innetlify.toml - Clear cache and redeploy: Deploys > Trigger deploy > Clear cache and deploy site
- Check Netlify’s Next.js Runtime version compatibility
Function Timeout Errors
Netlify Functions have a 10-second timeout on the free tier:- Optimize slow API routes
- Consider upgrading to Pro for 26-second timeouts
- Move long-running tasks to background jobs