Next.js: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Next.js = | |||
= About Next.js = | |||
[https://nextjs.org/ Next.js] is a popular full stack framework for node.js, it utilizes React for frontend and is packed with awesome features like server-side rendering. It also includes API routes and much more. | [https://nextjs.org/ Next.js] is a popular full stack framework for node.js, it utilizes React for frontend and is packed with awesome features like server-side rendering. It also includes API routes and much more. | ||
= Node.js Server Resource Usage = | |||
If you use Node.js, we strongly recommend that you [https://heliohost.org/dashboard/load/ monitor your site load here]. | If you use Node.js, we strongly recommend that you [https://heliohost.org/dashboard/load/ monitor your site load here]. | ||
Node apps often require a lot of server resources, and exceeding the account load limits will cause your user account to be [[: | Node apps often require a lot of server resources, and exceeding the account load limits will cause your user account to be [[:Suspension_Policy#High_Server_Usage|suspended for high server usage]]. | ||
= Setup = | |||
Go into your project root (if you don't have a project, learn how to create one [https://nextjs.org/learn/basics/create-nextjs-app here]) | Go into your project root (if you don't have a project, learn how to create one [https://nextjs.org/learn/basics/create-nextjs-app here]) | ||
Line 27: | Line 27: | ||
</pre> | </pre> | ||
= Server setup = | |||
Upload all your files to your Tommy server. Then go to the Node.js section and set the following: | Upload all your files to your Tommy server. Then go to the Node.js section and set the following: | ||
Line 37: | Line 37: | ||
* Optionally: Custom environment variables: `NODE\_ENV = production` | * Optionally: Custom environment variables: `NODE\_ENV = production` | ||
= Starting the server = | |||
Once all of the above steps are done, you can press the `Enable Node.js` button. | Once all of the above steps are done, you can press the `Enable Node.js` button. |
Revision as of 15:51, 4 October 2024
Next.js
About Next.js
Next.js is a popular full stack framework for node.js, it utilizes React for frontend and is packed with awesome features like server-side rendering. It also includes API routes and much more.
Node.js Server Resource Usage
If you use Node.js, we strongly recommend that you monitor your site load here.
Node apps often require a lot of server resources, and exceeding the account load limits will cause your user account to be suspended for high server usage.
Setup
Go into your project root (if you don't have a project, learn how to create one here)
Create a new file called `start.js` and put this inside:
const path = require('path'); const nextPath = path.join(__dirname, 'node_modules', '.bin', 'next'); process.argv.length = 1; process.argv.push(nextPath, 'start'); require(nextPath);
Server setup
Upload all your files to your Tommy server. Then go to the Node.js section and set the following:
- Node.js Version: At least 14.21.0 (though we highly recommend using the latest one: `17.9.1`)
- Application Root: / (Folder where you uploaded your next project, we recommend `/`)
- Application Startup File: `start.js` (the file created earlier)
- Custom environment variables: `PORT = 8888`
- Optionally: Custom environment variables: `NODE\_ENV = production`
Starting the server
Once all of the above steps are done, you can press the `Enable Node.js` button.
Then you need to press the `NPM install` button.
And then `Run script`, Script name: `build`
After that finishes, you will need to wait up to 2 hours for the server to update.
Node.js application deployment can take up to 2 hours to go into effect as it requires an Apache restart. After an entire 2 hours, if your Node app is not working for you, please clear your web browser cache.