अद्यतन 24 सित. 2025 को
6 मिनट
git push एक अद्वितीय प्रीव्यू URL बनाता है।main) सेट करके और अपनी PR मर्ज करके प्रोडक्शन में प्रमोट करें।npx create-next-app@latest my-appcd my-appnpm run devgit initgit add -Agit commit -m "init"git branch -M maingit remote add origin <your-repo-url>git push -u origin mainnpm install, npm run build और आउटपुट डायरेक्टरी जैसी डिफ़ॉल्ट सेटिंग सेट करता है।npm run dev)।NEXT_PUBLIC_ प्रीफ़िक्स के साथ क्लाइंट को सुरक्षित वैरिएबल एक्सपोज़ करें।NEXT_PUBLIC_API_BASE=DATABASE_URL=postgres://...JWT_SECRET=supersecretconst api = process.env.NEXT_PUBLIC_API_BASEconst conn = process.env.DATABASE_URLpages/api/hello.ts या app/api/hello/route.ts बनाएं।// app/api/hello/route.tsimport { NextResponse } from 'next/server'export async function GET {return NextResponse.json({ message: 'Hello from Vercel Functions!' })}middleware.ts:import { NextResponse } from 'next/server'import type { NextRequest } from 'next/server'export function middleware(req: NextRequest) {const country = req.geo?.country || 'US'const res = NextResponse.nextres.headers.set('x-country', country)return res}next/image स्वचालित रूप से Vercel के इमेज ऑप्टिमाइजेशन का उपयोग करता है।public/ में डालें। Vercel उन्हें एज पर सर्व और कैश करता है।export const revalidate = 60 // सेकंडmain को प्रोडक्शन के रूप में सेट किया गया है, तो Vercel स्वचालित रूप से प्रोडक्शन में प्रमोट करता है।vercel.json का उपयोग करें:{"buildCommand": "pnpm -w build","ignoreCommand": "git diff --quiet HEAD^ HEAD ./apps/web","framework": "nextjs"}dist) या Remix जैसे फ्रेमवर्क का उपयोग करते समय आउटपुट डायरेक्टरी सेट करें।रूट हैंडलर, सर्वर एक्शन, dynamic = 'force-dynamic' और कैशिंग डायरेक्टिव जैसी ऐप राउटर सुविधाएँ सीधे Vercel इन्फ़्रा में मैप होती हैं।// app/api/products/route.tsimport { NextResponse } from 'next/server'export async function GET {const data = await fetch(' { next: { revalidate: 3600 } })return NextResponse.json(await data.json)}export const dynamic = 'force-dynamic' // स्टैटिक रेंडरिंग से बाहर निकलेंexport const runtime = 'edge'next.config.js या vercel.json के माध्यम से रीडायरेक्ट और रीराइट:// next.config.jsmodule.exports = {async redirects {return lets you chat with AI on any page—handy for generating config snippets, summarizing PR previews, or drafting post-deploy checklists right from the Vercel dashboard.---## Next Steps: Ship Something Today- Create a small Next.js app and deploy it to a preview URL.- Add a custom domain and try a redirect.- Introduce one Edge Middleware rule (like a geo header or simple auth gate).- Hook up error monitoring and check logs after a few test requests.Once you’ve done this once, you’ll understand not just how to use Vercel, but how to use it to move faster than your process used to allow.---## Key Takeaways- How to use Vercel in practice: connect Git → deploy → preview → merge to prod.- Lean on built-in features: Edge Middleware, serverless functions, ISR, image optimization.- Separate envs and automate feedback via previews for every PR.- Add a domain early; monitor logs and web vitals from day one.- Optimize cost with caching, ISR, and thoughtful runtime choices.### FAQQ1:What is the fastest way to learn how to use Vercel?Connect your Git repo, deploy a starter (like Next.js), and explore preview URLs on each push. Then add environment variables, a custom domain, and a simple API route to cover the core workflow.Q2:How to use Vercel with Next.js for best performance?Use ISR (`revalidate`), `next/image` optimization, and Edge Middleware for lightweight logic. Cache external fetches and choose edge or serverless runtimes based on workload.Q3:Can I use Vercel without Next.js?Yes—Vercel supports frameworks like Astro, SvelteKit, Remix, and Nuxt. Ensure the correct build command and output directory are set, and use `vercel.json` if you need custom routing.Q4:How do I set environment variables on Vercel?In the Vercel dashboard, go to Project → Settings → Environment Variables and add values for Development, Preview, and Production. Use `NEXT_PUBLIC_` for variables that must be exposed to the client.Q5:How to use Vercel for custom domains and SSL?Add your domain under Project → Domains; Vercel provisions SSL automatically. Point your DNS records (CNAME or A/ALIAS) to Vercel and verify in the dashboard.
कैसे करें ChatPDF में महारत: घने दस्तावेज़ों से तेजी से जानकारी प्राप्त करें

तेज़ और सटीक दस्तावेज़ों के लिए सर्वश्रेष्ठ X Auto-Translation विकल्प

ईरान में Samsung AI अनुवाद उपलब्ध नहीं? व्यावहारिक समाधान

फ़ारसी अनुवाद उपकरण: तेज़ और सटीक काम के लिए एक व्यावहारिक मार्गदर्शिका

गहराई से संदर्भित अनुसंधान के लिए सर्वश्रेष्ठ Grok विकल्प

AI इमेज जेनरेटर की 15 बेहतरीन विशेषताएं जिनका आप वास्तव में उपयोग करेंगे