npm run dev
To deploy your Next.js application, you primarily need the contents of the .next directory, which contains the build output. Here is a brief overview of the relevant files and folders within the .next directory:
.next/static/: Contains static assets such as JavaScript and CSS files. .next/server/: Contains server-side rendered pages and API routes. .next/BUILD_ID: Contains the build ID used for cache busting. .next/required-server-files.json: Contains information about the server configuration and required files.
To deploy your app, you typically need to include the following:
The .next directory. The package.json file. The next.config.js file (if you have one). The public directory (if you have one).
(Static): The page is prerendered as static content. This means the HTML is generated at build time and will be served as a static file. This is the default behavior for pages that do not use getStaticProps or getServerSideProps.
● (SSG): The page is prerendered as static HTML using getStaticProps. SSG stands for Static Site Generation. The HTML is generated at build time, but you can also fetch data and include it in the prerendered HTML.
ƒ (Dynamic): The page is server-rendered on demand using getServerSideProps. This means the HTML is generated on each request, allowing you to fetch data that changes frequently or is user-specific.
To deploy your Next.js application with dynamic server-side rendering (SSR), you need to ensure that your pages use getServerSideProps for data fetching. This will make your pages server-rendered on demand.
npm install -g vercel vercel
To deploy your Next.js application as static content, you need to ensure that all your pages are statically generated. This can be achieved by using getStaticProps for data fetching and getStaticPaths for dynamic routes.
dynamic routes // filepath: /pages/[id].js
The next export command has been deprecated in favor of using the output: 'export' configuration in next.config.js