Installation Guide
This guide covers the complete installation process for the NJ Rajat Mahotsav event platform, including all environment variables, database setup, and third-party integrations.If you just want to get started quickly, check out the Quickstart Guide instead. This guide is for production-ready setup.
Prerequisites
Before you begin, ensure you have:Node.js 18+
Download from nodejs.org
npm
Comes bundled with Node.js
Git
For version control and deployment
Supabase Account
Free tier available at supabase.com
Cloudflare Account
For R2 storage and Images CDN
Google Cloud Console
For OAuth authentication (admin only)
Step 1: Clone and Install
Step 2: Environment Variables
Create a.env.local file in your project root with all required environment variables.
Environment Variable Reference
Supabase Variables (Required)
Supabase Variables (Required)
These variables are required for the application to function:
Usage in code:
| Variable | Description | Where to find |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Your Supabase project URL | Supabase Dashboard → Settings → API → Project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase anonymous public key | Supabase Dashboard → Settings → API → Project API keys → anon public |
The client supports both
NEXT_PUBLIC_SUPABASE_ANON_KEY and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY for backward compatibility.utils/supabase/client.ts
Cloudflare R2 Variables (Optional)
Cloudflare R2 Variables (Optional)
These variables are required for file uploads (community seva, spiritual seva):
Usage in code:
| Variable | Description | Where to find |
|---|---|---|
R2_ENDPOINT | R2 storage endpoint URL | Cloudflare Dashboard → R2 → Settings → S3 API endpoint |
R2_ACCESS_KEY_ID | R2 API access key ID | Cloudflare Dashboard → R2 → Manage R2 API Tokens |
R2_SECRET_ACCESS_KEY | R2 API secret access key | Generated when creating R2 API token |
R2_BUCKET_NAME | Name of your R2 bucket | The bucket you created in Cloudflare R2 |
R2_BUCKET_PREFIX | Prefix for uploaded files | Default: uploads/ (customizable) |
app/api/generate-upload-ursl.ts
Cloudflare Images Configuration
Cloudflare Images Configuration
Cloudflare Images is used for optimized image delivery with responsive variants.The configuration is hardcoded in To use your own Cloudflare Images account:
lib/cdn-assets.ts:lib/cdn-assets.ts
- Update
CLOUDFLARE_IMAGES_BASEwith your account hash - Update
CDN_BASE_URLwith your R2 public URL or custom domain - Configure image variants in Cloudflare Dashboard:
bigger,mobileWP,biggest
Step 3: Supabase Setup
Create a Supabase project
- Go to Supabase Dashboard
- Click New Project
- Choose your organization
- Enter project details:
- Name: NJ Rajat Mahotsav
- Database Password: Generate a strong password
- Region: Choose the closest to your users
- Click Create new project
Project creation takes 2-3 minutes. You’ll receive an email when it’s ready.
Set up Google OAuth (for admin dashboard)
The admin dashboard requires Google OAuth authentication. Follow these steps:
-
Create Google OAuth credentials:
- Go to Google Cloud Console
- Create a new project or select existing
- Navigate to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Choose Web application
- Add authorized redirect URIs:
http://localhost:3000/auth/callback(development)https://your-domain.com/auth/callback(production)https://your-project.supabase.co/auth/v1/callback(Supabase)
-
Configure Supabase:
- In Supabase Dashboard, go to Authentication → Providers
- Enable Google
- Paste your Google Client ID and Client Secret
- Save
-
Add redirect URLs to Supabase:
- Go to Authentication → URL Configuration
- Add your callback URLs:
http://localhost:3000/auth/callbackhttps://your-domain.com/auth/callback
Step 4: Cloudflare R2 Setup (Optional)
Create an R2 bucket
- Go to Cloudflare Dashboard
- Navigate to R2 → Overview
- Click Create bucket
- Enter a bucket name (e.g.,
rajat-mahotsav-uploads) - Choose a location hint (closest to your users)
- Click Create bucket
Generate R2 API tokens
- In Cloudflare Dashboard, go to R2 → Overview
- Click Manage R2 API Tokens
- Click Create API token
- Configure permissions:
- Token name: NJ Rajat Mahotsav API
- Permissions: Object Read & Write
- TTL: No expiry (or set according to your policy)
- Click Create API token
- Copy the following values:
- Access Key ID (for
R2_ACCESS_KEY_ID) - Secret Access Key (for
R2_SECRET_ACCESS_KEY) - Endpoint URL (for
R2_ENDPOINT)
- Access Key ID (for
Step 5: Run the Application
- Development
- Production
Start the development server:The application will be available at
http://localhost:3000.The dev server supports hot module replacement (HMR) - your changes will appear instantly.
Step 6: Verify Installation
Test the homepage
Navigate to
http://localhost:3000 and verify:- Page loads without errors
- Images display correctly via Cloudflare CDN
- Animations work smoothly
- Navigation is functional
Test event registration
- Go to
http://localhost:3000/registration - Fill out the registration form with test data:
- Name: Test User
- Age: 25
- Ghaam: TestGhaam
- Country: USA
- Mandal: New Jersey
- Email: [email protected]
- Phone: +1 234-567-8900
- Dates: July 27 - August 2, 2026
- Submit the form
- Verify success message appears
- Check Supabase Dashboard → Table Editor → registrations for the new record
Test admin dashboard (if OAuth configured)
- Navigate to
http://localhost:3000/admin/registrations - Click Sign in with Google
- Complete Google OAuth flow
- Verify you can see:
- Dashboard statistics
- Registration table with data
- Charts and visualizations
- CSV export functionality
Admin access is restricted by email domain. Update
lib/admin-auth.ts to allow your email domain.Configuration Files
Key configuration files you may need to modify:next.config.mjs
next.config.mjs
Next.js configuration with custom webpack setup:
next.config.mjs
tailwind.config.js
tailwind.config.js
Tailwind CSS configuration with custom theme:
- Custom color palette with preset colors
- Custom font families (Figtree, Instrument Serif, Gujarati fonts)
- Custom spacing variables
- Extended animations
tailwind.config.jsmiddleware.ts
middleware.ts
Next.js middleware for session management:This middleware ensures Supabase sessions are refreshed on each request.
middleware.ts
lib/admin-auth.ts
lib/admin-auth.ts
Admin domain validation:Update
ALLOWED_DOMAIN to match your organization’s email domain.Deployment
The platform is optimized for deployment on Vercel:Deploy to Vercel
- Go to Vercel Dashboard
- Click Add New → Project
- Import your GitHub repository
- Configure environment variables:
- Add all variables from your
.env.local - Mark sensitive variables as “Sensitive” to hide them
- Add all variables from your
- Click Deploy
Troubleshooting
Supabase connection issues
Supabase connection issues
Problem: “Supabase is not configured” errorSolutions:
- Verify
.env.localexists in project root - Restart the dev server after adding/changing environment variables
- Check that
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYare correct - Ensure your Supabase project is active (not paused)
- Check browser console for specific error messages
OAuth redirect_uri_mismatch
OAuth redirect_uri_mismatch
Problem: “Error 400: redirect_uri_mismatch” during Google OAuthSolutions:
- Verify callback URL in Google Cloud Console:
- Must include
http://localhost:3000/auth/callbackfor local - Must include your Supabase callback URL
- Must include
- Check Supabase redirect URL allowlist:
- Go to Authentication → URL Configuration
- Add
http://localhost:3000/auth/callback
- Ensure no trailing slashes in URLs
- Wait a few minutes after updating Google OAuth settings (changes can take time to propagate)
R2 upload failures
R2 upload failures
Problem: File uploads fail with S3 errorsSolutions:
- Verify R2 credentials in
.env.local:R2_ENDPOINTshould includehttps://R2_ACCESS_KEY_IDandR2_SECRET_ACCESS_KEYmust be correct
- Check bucket permissions:
- API token must have “Object Read & Write” permissions
- Verify bucket name matches
R2_BUCKET_NAME - Check CORS configuration if uploading from browser
- Check Cloudflare R2 dashboard for error logs
Images not loading
Images not loading
Problem: Images show broken or don’t loadSolutions:
- Verify Cloudflare Images configuration in
lib/cdn-assets.ts - Check that image IDs are correct
- Ensure images are uploaded to your Cloudflare Images account
- Test image URLs directly in browser
- Check browser console for CORS errors
- Verify image variants are configured:
bigger,mobileWP,biggest
Build errors
Build errors
Problem:
npm run build failsSolutions:- Clear Next.js cache:
- Check Node.js version:
node --version(must be 18+) - Delete and reinstall dependencies:
- Check for TypeScript errors (even though builds ignore them)
- Verify all environment variables are set
Session not persisting
Session not persisting
Problem: Users logged out after page refreshSolutions:
- Check that middleware.ts is running:
- Verify matcher patterns include your protected routes
- Verify cookies are not blocked:
- Check browser privacy settings
- Ensure third-party cookies are allowed for local development
- Check Supabase session duration settings
- Inspect cookies in browser DevTools:
- Look for
sb-*-auth-tokencookies
- Look for
- Verify middleware is refreshing sessions correctly
Next Steps
Architecture Overview
Learn about the application architecture and design patterns
Component Structure
Understand atomic design and component organization
Supabase Integration
Deep dive into Supabase setup and Row Level Security
Cloudflare CDN
Configure R2 storage and image optimization
Production Checklist: Before deploying to production, review the security section in the README and update admin domain restrictions in
lib/admin-auth.ts.