Step 1: Set Up Your Next.js App
Install Node.js: If you haven’t already, download and install Node.js from here.
Create a Next.js app: Open your terminal and run the following command to create a new Next.js app:
npx create-next-app your-nextjs-app
BashNavigate into your app directory:
cd your-nextjs-app
BashStart the development server:
npm run dev
BashThis command will start a development server and your app will be accessible at http://localhost:3000.
Step 2: Build Your Next.js App
Once you are ready to deploy your app, you need to build it. Run the following command in your terminal:
npm run build
Bashএই কমান্ডার ফলে .next নামে ফোল্ডারে এপ্লিকেশন টি বিল্ড হবে প্রোডাকশন ভার্সন এ এই ফাইলটি আমরা সিপ্যানেল এর ফাইল ম্যানেজার এ আপলোড করবো।
Step 3: Run Your Next.js App from server.js
এবার প্রজেক্টের root ডিরেক্টরিতে server.js নামে একটা ফাইল তৈরী করবো
const next = require('next');
const http = require('http');
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
http.createServer((req, res) => {
handle(req, res);
}).listen(3000, (err) => {
if (err) throw err;
console.log('> Ready on http://localhost:3000');
});
});
Bashpackages.json ফাইলে বলে দেব স্টার্ট কমান্ড এ কোন ফাইলটি রান হবে
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "node server.js",
"lint": "next lint"
},
Bashএবার সিপ্যানেল এ nodejs এপ্লিকেশন বানাই এবং ডেপ্লয় করি যেভাবে nodejs ডেপ্লয় করে link