Next.js ले धेरै deployment targets समर्थन गर्छ, जो आंशिक रूपमा output config द्वारा नियन्त्रित हुन्छ। सही चयन तपाईंलाई Node server, containers, वा शुद्ध static hosting चाहिन्छ कि छैन भन्ने कुरामा निर्भर गर्छ।
build output modes
. = {
};
Next.js ले धेरै deployment targets समर्थन गर्छ, जो आंशिक रूपमा output config द्वारा नियन्त्रित हुन्छ। सही चयन तपाईंलाई Node server, containers, वा शुद्ध static hosting चाहिन्छ कि छैन भन्ने कुरामा निर्भर गर्छ।
. = {
};
Node.js server चलाउँछ, त्यसैले तपाईंले सबै कुरा पाउनुहुन्छ: SSR, ISR, Server Actions, Route Handlers, image optimization, middleware। यो Vercel (Next.js को निर्माता, zero-config) र Node hosts जस्तै platforms द्वारा प्रयोग गरिन्छ।
# Next traces only the needed files into .next/standalone → a tiny, self-contained server
COPY --from=builder /app/.next/standalone ./
CMD ["node", "server.js"]
standalone ले केवल वास्तवमा प्रयोग गरिने dependencies सहितको न्यूनतम फोल्डर उत्पादन गर्छ, AWS, GCP, तपाईंको आफ्नो servers, इत्यादिमा साना Docker images को लागि आदर्श। तपाईं सबै server features राख्नुहुन्छ।
next build → out/ (plain HTML/CSS/JS, deployable to any static host: S3, GitHub Pages, Netlify CDN)
Static export ले सबैभन्दा सस्तो, सबैभन्दा सरल hosting दिन्छ तर server features अक्षम गर्छ: कुनै SSR छैन, कुनै ISR छैन, कुनै Route Handlers छैन, कुनै Server Actions छैन, कुनै on-the-fly image optimization छैन। केवल पूर्ण static sites को लागि उपयुक्त।
Need SSR/ISR/Server Actions, want zero-config → Vercel (or a Node host) — default output
Want containers / self-host with full features → output: "standalone" + Docker
Purely static content (docs, marketing) → output: "export" → any static CDN
- Runtime choice (Edge vs Node) affects where functions run
- Self-hosting ISR/caching needs persistent storage or a shared cache
- Image optimization on non-Vercel hosts may need a custom loader
Deployment एक आकार-फिट-सबै चीज होइन: output mode निर्धारण गर्छ कि कुन Next.js features जीवित रहन्छ।
default/Node output सबै server capabilities राख्छ, standalone ले तिनलाई Docker/self-hosting को लागि प्याकेज गर्छ, र export ले शुद्ध static hosting को लागि सबै server features बदल्छ भन्ने कुरा जान्दै तपाईंलाई build लाई तपाईंको infrastructure सँग मेल गर्न दिन्छ — र output: "export" SSR/ISR/Server Actions लाई चुपचाप तोड्ने trap बचाउँछ।