This guide will walk you through deploying your ACalc food tracking app to either Vercel or Netlify.
- A GitHub account
- Your ACalc project committed to Git (which you've already done)
- Go to GitHub and sign in.
- Click the "+" icon in the top right corner and select "New repository".
- Name your repository (e.g., "acalc").
- Keep it public or private based on your preference.
- Click "Create repository".
Run these commands in your project directory:
# Add the remote repository (replace YOUR_USERNAME with your GitHub username)
git remote add origin https://github.com/YOUR_USERNAME/acalc.git
# Push your code to GitHub
git push -u origin master-
Go to Vercel and sign up or sign in.
-
Click "Add New..." and select "Project".
-
Connect your GitHub account if you haven't already.
-
Select the repository you just created.
-
Configure your project:
- Framework Preset: Next.js
- Root Directory: ./
- Build Command: npm run build
- Install Command: npm install
- Output Directory: .next
-
Environment Variables: Add these environment variables from your
.envfile:NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYNEXT_PUBLIC_NUTRITIONIX_APP_IDNEXT_PUBLIC_NUTRITIONIX_APP_KEYNEXT_PUBLIC_APP_URL(set this to your Vercel deployment URL, likehttps://acalc.vercel.app)
-
Click "Deploy" and wait for your project to build and deploy.
- Once the deployment is complete, Vercel will provide you with a URL.
- Visit the URL to ensure your app is functioning correctly.
- Test the authentication, food journal, and barcode scanning features.
Follow the GitHub repository creation steps from Option 1.
Follow the GitHub push steps from Option 1.
-
Go to Netlify and sign up or sign in.
-
Click "New site from Git".
-
Select "GitHub" as your Git provider.
-
Authorize Netlify to access your GitHub repositories.
-
Select the repository you just created.
-
Configure your build settings:
- Branch to deploy:
master(ormain) - Build command:
npm run build - Publish directory:
.next
- Branch to deploy:
-
Environment Variables: Add the same environment variables as listed in the Vercel deployment.
-
Click "Deploy site" and wait for your project to build and deploy.
- Once the deployment is complete, Netlify will provide you with a URL.
- Visit the URL to ensure your app is functioning correctly.
- Test the authentication, food journal, and barcode scanning features.
If you encounter build errors during deployment:
- Check the build logs provided by Vercel or Netlify.
- Make sure all dependencies are properly listed in your
package.json. - Ensure your Next.js version is compatible with your code.
- Try rebuilding with a clean cache.
If your app deploys but doesn't work correctly:
- Verify that all environment variables are correctly set in the Vercel or Netlify dashboard.
- Check that your Supabase and NutritionIx credentials are valid.
- Ensure the
NEXT_PUBLIC_APP_URLis set to your deployment URL.
If you experience CORS (Cross-Origin Resource Sharing) issues:
- Go to your Supabase dashboard.
- Navigate to Settings > API.
- Add your deployed app URL to the list of allowed origins.
Both Vercel and Netlify support continuous deployment. Any changes pushed to your GitHub repository will automatically trigger a new deployment.
To use a custom domain:
- Purchase a domain from a domain registrar (like Namecheap, GoDaddy, etc.).
- In Vercel or Netlify, go to your project settings and find the "Domains" section.
- Add your custom domain and follow the instructions to configure DNS settings.
Your ACalc food tracking app should now be live and accessible on the web. Congratulations!