Next.js - Deployment (2024)

'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });

So far we've developed and run sample NEXT.JS application in dev mode, now we'll do the production ready deployment locally using following steps.

The production ready build lacks source maps and hot code reloading as compared to dev mode as those features are primarily used in debugging.

Prepare Build

Run the following command to prepare production ready build −.

npm run build> nextjs@1.0.0 build \Node\nextjs> next buildinfo - Loaded env from \Node\nextjs\.env.localCreating an optimized production buildCompiled successfully.Automatically optimizing pagesPage Size First Load JS+ ? / 2.25 kB 60.3 kB+ /_app 288 B 58.1 kB+ /404 3.25 kB 61.3 kB+ ? /api/user+ ? /posts/[id] 312 B 61.6 kB+ + /posts/one+ + /posts/two+ ? /posts/env 2.71 kB 60.8 kB+ ? /posts/first 374 B 61.7 kB+ First Load JS shared by all 58.1 kB + static/pages/_app.js 288 B + chunks/3458401054237127135bcd3ee8eb2a19d67af299.a1a019.js 10.5 kB + chunks/framework.c6faae.js 40 kB + runtime/main.60464f.js 6.54 kB + runtime/webpack.c21266.js 746 B + css/9706b5b8ed8e82c0fba0.css 175 B? (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps) (Static) automatically rendered as static HTML (uses no initial props)? (SSG) automatically generated as static HTML + JSON (uses getStaticProps)

Start the server

Run the following command to start production server −.

npm run start> nextjs@1.0.0 start \Node\nextjs> next startinfo - Loaded env from \Node\nextjs\.env.localready - started server on http://localhost:3000

Verify Output

Open localhost:3000/api/user in a browser and you will see the following output.

{"name":"Robert"}

Advertisem*nts

';adpushup.triggerAd(ad_id); });

Next.js - Deployment (2024)
Top Articles
Latest Posts
Article information

Author: Jeremiah Abshire

Last Updated:

Views: 5624

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Jeremiah Abshire

Birthday: 1993-09-14

Address: Apt. 425 92748 Jannie Centers, Port Nikitaville, VT 82110

Phone: +8096210939894

Job: Lead Healthcare Manager

Hobby: Watching movies, Watching movies, Knapping, LARPing, Coffee roasting, Lacemaking, Gaming

Introduction: My name is Jeremiah Abshire, I am a outstanding, kind, clever, hilarious, curious, hilarious, outstanding person who loves writing and wants to share my knowledge and understanding with you.