Skip to content

Latest commit

Β 

History

History
485 lines (344 loc) Β· 9.6 KB

File metadata and controls

485 lines (344 loc) Β· 9.6 KB

πŸš€ Vercel Deployment Guide - TruthChain

βœ… Quick Deploy to Vercel

Deploy your TruthChain application to Vercel in just a few clicks!


🎯 Option 1: Deploy via Vercel Dashboard (Recommended)

Step 1: Go to Vercel

  1. Visit Vercel:

  2. Sign up / Log in:

    • Use GitHub account (recommended)
    • Click "Continue with GitHub"
    • Authorize Vercel

Step 2: Import Your Repository

  1. Click "Add New Project"

  2. Import Git Repository:

    • Click "Import Git Repository"
    • Select "GitHub"
    • Find An8akki/truthchain
    • Click "Import"

Step 3: Configure Project

Framework Preset:

  • Vercel should auto-detect: Next.js

Root Directory:

  • Set to: frontend
  • Click "Edit" next to Root Directory
  • Enter: frontend

Build and Output Settings:

  • Build Command: npm run build (auto-detected)
  • Output Directory: .next (auto-detected)
  • Install Command: npm install (auto-detected)

Environment Variables:

  • Skip for now (optional, can add later)

Step 4: Deploy!

  1. Click "Deploy"

    • Vercel will start building
    • Wait 2-3 minutes
  2. Deployment Complete!

    • You'll see: "Congratulations!"
    • Your app is live!
  3. Get Your URL:

    • Format: https://truthchain-xxx.vercel.app
    • Click "Visit" to see your live app

🎯 Option 2: Deploy via Vercel CLI

Step 1: Install Vercel CLI

npm install -g vercel

Step 2: Login to Vercel

vercel login
  • Choose your login method (GitHub recommended)
  • Authorize in browser

Step 3: Deploy

# Navigate to project root
cd d:\BlockChain\TruthChain

# Deploy
vercel

# Follow prompts:
# - Set up and deploy? Yes
# - Which scope? Your account
# - Link to existing project? No
# - Project name? truthchain
# - Directory? ./frontend
# - Override settings? No

Step 4: Production Deployment

# Deploy to production
vercel --prod

πŸ“‹ Deployment Configuration

vercel.json (Already Created)

{
  "buildCommand": "cd frontend && npm install && npm run build",
  "outputDirectory": "frontend/.next",
  "devCommand": "cd frontend && npm run dev",
  "installCommand": "cd frontend && npm install",
  "framework": "nextjs",
  "regions": ["iad1"]
}

Project Structure for Vercel

TruthChain/
β”œβ”€β”€ frontend/              ← Root directory for Vercel
β”‚   β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ contexts/
β”‚   β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   └── next.config.js
β”œβ”€β”€ contracts/
β”œβ”€β”€ scripts/
β”œβ”€β”€ vercel.json           ← Vercel configuration
└── README.md

πŸ”§ Environment Variables (Optional)

If you want to add environment variables on Vercel:

Step 1: Go to Project Settings

  1. Go to your Vercel dashboard
  2. Select your project
  3. Click "Settings"
  4. Click "Environment Variables"

Step 2: Add Variables

Add these if needed:

NEXT_PUBLIC_CREATOR_REGISTRY_ADDRESS=0x...
NEXT_PUBLIC_TRUTHCHAIN_ADDRESS=0x...
NEXT_PUBLIC_NETWORK_NAME=polygonAmoy
NEXT_PUBLIC_CHAIN_ID=80002
NEXT_PUBLIC_RPC_URL=https://rpc-amoy.polygon.technology
NEXT_PUBLIC_PINATA_API_KEY=your_key
NEXT_PUBLIC_PINATA_SECRET_KEY=your_secret
NEXT_PUBLIC_PINATA_JWT=your_jwt

Note: For demo mode, these are optional!


🎨 Custom Domain (Optional)

Add Your Own Domain

  1. Go to Project Settings:

    • Click "Domains"
  2. Add Domain:

    • Enter your domain (e.g., truthchain.com)
    • Follow DNS configuration instructions
  3. Vercel Provides:

    • Free SSL certificate
    • Automatic HTTPS
    • Global CDN

πŸš€ Deployment Process

What Happens When You Deploy:

  1. Vercel Clones Your Repo

    • From GitHub: An8akki/truthchain
  2. Installs Dependencies

    • Runs: npm install in frontend/
  3. Builds Your App

    • Runs: npm run build
    • Creates optimized production build
  4. Deploys to CDN

    • Distributes globally
    • Enables edge caching
  5. Provides URL

    • Format: https://truthchain-xxx.vercel.app
    • Or your custom domain

πŸ“Š Expected Build Output

Building...
βœ“ Compiled successfully
βœ“ Linting and checking validity of types
βœ“ Collecting page data
βœ“ Generating static pages (5/5)
βœ“ Finalizing page optimization

Route (app)                              Size     First Load JS
β”Œ β—‹ /                                    5.2 kB         95 kB
β”œ β—‹ /admin                               8.1 kB         98 kB
β”œ β—‹ /creator                             12.3 kB        102 kB
β”œ β—‹ /explore                             7.8 kB         97 kB
β”” β—‹ /verify                              9.5 kB         99 kB

β—‹  (Static)  prerendered as static content

βœ“ Build completed successfully

βœ… Verify Deployment

After Deployment:

  1. Visit Your URL:

    https://truthchain-xxx.vercel.app
    
  2. Test All Pages:

    • Home: /
    • Verify: /verify
    • Creator: /creator
    • Explore: /explore
    • Admin: /admin
  3. Check Features:

    • βœ… Cosmos background loads
    • βœ… Navigation works
    • βœ… Creator registration works
    • βœ… Content upload works
    • βœ… Verification works
    • βœ… All features functional

πŸ”„ Automatic Deployments

How It Works:

  1. Push to GitHub:

    git add .
    git commit -m "Update feature"
    git push
  2. Vercel Auto-Deploys:

    • Detects push to master branch
    • Automatically builds and deploys
    • Updates live site in 2-3 minutes
  3. Preview Deployments:

    • Every branch gets a preview URL
    • Test before merging to master

🎯 Deployment Checklist

Before Deploying:

  • Code pushed to GitHub
  • vercel.json created
  • Frontend builds locally (npm run build)
  • No build errors
  • All features tested

During Deployment:

  • Vercel project created
  • Root directory set to frontend
  • Build completes successfully
  • Deployment URL received

After Deployment:

  • Visit deployment URL
  • Test all pages
  • Verify features work
  • Check console for errors
  • Share with users!

πŸ› Troubleshooting

Build Fails

Error: "Build failed"

Solution:

  1. Check build logs in Vercel dashboard
  2. Test build locally:
    cd frontend
    npm run build
  3. Fix any errors
  4. Push to GitHub
  5. Vercel will auto-redeploy

404 on Routes

Error: "404 Not Found" on /creator, /verify, etc.

Solution:

  • Ensure root directory is set to frontend
  • Next.js should handle routing automatically
  • Check next.config.js if exists

Environment Variables Not Working

Error: "undefined" for environment variables

Solution:

  1. Add variables in Vercel dashboard
  2. Redeploy after adding variables
  3. Ensure variables start with NEXT_PUBLIC_

Slow Loading

Issue: App loads slowly

Solution:

  • Vercel uses global CDN (should be fast)
  • Check image optimization
  • Enable caching headers
  • Use Vercel Analytics to diagnose

πŸ“ˆ Vercel Features You Get

Free Tier Includes:

  • βœ… Unlimited Deployments
  • βœ… Automatic HTTPS
  • βœ… Global CDN
  • βœ… Preview Deployments
  • βœ… Auto-scaling
  • βœ… 100GB Bandwidth/month
  • βœ… Serverless Functions
  • βœ… Analytics (optional)

Performance:

  • ⚑ Edge Network: 70+ locations worldwide
  • ⚑ Fast Builds: 2-3 minutes average
  • ⚑ Instant Rollbacks: One-click revert
  • ⚑ Zero Downtime: Atomic deployments

πŸ”— Useful Links

Vercel Dashboard:

Documentation:


πŸŽ‰ One-Click Deploy Button

Add this to your README.md:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/An8akki/truthchain&project-name=truthchain&repository-name=truthchain&root-directory=frontend)

This creates a button that deploys your app with one click!


πŸ“Š Deployment Summary

What You Get:

🌐 Live URL:          https://truthchain-xxx.vercel.app
πŸš€ Deploy Time:       2-3 minutes
πŸ”„ Auto-Deploy:       On every push to master
🌍 Global CDN:        70+ edge locations
πŸ“Š Analytics:         Built-in (optional)
πŸ”’ HTTPS:             Automatic SSL
πŸ’° Cost:              FREE (Hobby plan)

βœ… Quick Deploy Steps

TL;DR - Just Do This:

  1. Go to: https://vercel.com/new
  2. Import: An8akki/truthchain
  3. Set Root Directory: frontend
  4. Click: "Deploy"
  5. Wait: 2-3 minutes
  6. Done! Visit your live URL

🎯 Next Steps After Deployment

  1. Share Your URL:

    • Post on social media
    • Share with friends
    • Add to portfolio
  2. Monitor Performance:

    • Check Vercel Analytics
    • Monitor build times
    • Track visitor stats
  3. Keep Updating:

    • Push to GitHub
    • Vercel auto-deploys
    • Always stay current
  4. Add Custom Domain:

    • Buy a domain
    • Point DNS to Vercel
    • Get professional URL

πŸ†˜ Need Help?


πŸŽ‰ Your TruthChain app is ready to deploy to Vercel! πŸš€

Deploy Now: https://vercel.com/new


Last Updated: 2025-11-29
For TruthChain v1.0