gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
How can I integrate next-on-pages to an existing project?
- User
How can I integrate next-on-pages to an existing project?
- Assistant
To integrate Next.js into an existing project, follow these steps:
- Install Next.js in your project by running the following command in your terminal:
npm install next react react-dom- Create a pages directory in your project root directory and add a new file, for example:
index.js
// pages/index.js const Home = () => { return <h1>Welcome to Next.js!</h1> } export default Home- Update your package.json file to configure Next.js scripts:
"scripts": { "dev": "next", "build": "next build", "start": "next start" }- Run Next.js in development mode using the following command:
npm run devNext.js will start a development server and your existing project will be accessible at http://localhost:3000
- You can start adding new pages to your project by creating additional files in the pages directory. Next.js automatically routes URLs to these files based on their file names.