Vercel पर Deploy करना
In this page:
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}
Zero-Config Deployment
Vercel common frameworks को अपने आप detect करता है (Vite, Create React App, और खासकर Next.js शामिल) और सही build command और output directory configure कर देता है बिना आपको manually कुछ specify किए, ज़्यादातर standard project setups में।
उदाहरण: Deploying to Vercel from the CLI
$ npm install -g vercel
$ vercel login
$ vercel
# Vercel detects the Vite/CRA config automatically and deploys a preview
$ vercel --prod
⚠️ Run this in your own terminal or Node.js environment.
Client-Side Routing Handle करना
Netlify की तरह ही, एक React Router single-page app को Vercel को हर route के लिए index.html serve करने के लिए configured चाहिए, React Router को असल routing client-side पर handle करने देते हुए, बजाय Vercel के हर path के लिए एक असली file ढूंढने की कोशिश करने (और fail होने) के।
उदाहरण: The vercel.json Rewrite
$ cat vercel.json
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}
⚠️ Run this in your own terminal or Node.js environment.
Production vs. Preview Environment Variables
Vercel हर pull request को अपने आप इसका अपना Preview deployment के रूप में deploy करता है, आपकी main branch से जुड़ी Production deployment से अलग। Environment variables दोनों के लिए अलग तरीके से configure किए जा सकते हैं, preview deployments को एक staging API पर point करने देते हुए जबकि production असली वाली पर point करती है।
उदाहरण: Setting Vercel Environment Variables per Environment
$ vercel env add VITE_API_URL production
$ vercel env add VITE_API_URL preview
⚠️ Run this in your own terminal or Node.js environment.
- यह न realize करना कि Vercel की zero-config detection usually एक standard Vite/React app अपने आप handle कर लेती है, इसलिए manually build settings override करना कभी-कभी इसे solve करने से ज़्यादा problems का कारण बन सकता है।
- यह भूल जाना कि Vercel को भी client-side routing के लिए एक rewrite rule चाहिए, Netlify के redirect जैसा।
- Preview deployments (per pull request) को Production deployments (main branch) से confuse करना यह check करते समय कि कौन से environment variables apply होते हैं।
- Vercel एक और popular hosting platform है, जिसका Next.js (इसका अपना creator) के साथ-साथ plain React apps के लिए भी particularly strong support है।
- यह common frameworks के लिए अक्सर build settings को बिना किसी manual configuration के auto-detect करता है।
- Vercel पर client-side routing को एक rewrite rule (
vercel.json) चाहिए, Netlify के redirect के equivalent। - Vercel Production deployments (main branch) को Preview deployments (दूसरी branches/PRs) से अलग करता है, हर एक potentially अलग environment variables के साथ।
कोई React-version restriction नहीं — एक hosting/deployment workflow है, कोई code feature नहीं।
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first:
- Why Performance Matters
- Optimizing with React.memo
- Avoiding Unnecessary Re-renders
- Using the React Profiler
- Analyzing Bundle Size
- Image Optimization Techniques
- React as a PWA
- Creating a Production Build
- Environment Variables in React
- Deploying to Netlify
- Deploying to Vercel
- Basic CI/CD for React Apps
- SEO Basics for React SPAs