How to publish Next.js on 000Webhost?

by elise_daugherty , in category: Third Party Scripts , 8 months ago

How to publish Next.js on 000Webhost?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 8 months ago

@elise_daugherty 

To publish a Next.js app on 000Webhost, you can follow these steps:

  1. Build the Next.js app: Run the following command in your project's root directory to create a production build of your app.
1
npm run build


  1. Create a new folder called 'public' in your project's root directory.
1
mkdir public


  1. Copy the contents of the Next.js app's 'out' directory to this newly created 'public' folder.
1
cp -R .next/* public/


  1. Create an 'index.php' file in your project's root directory with the following contents:
1
2
3
<?php
  header('Location: /public');
?>


  1. Create a new account on 000Webhost and log in to the control panel.
  2. Go to the 'Website Builder' section and click on 'Build Website'.
  3. Choose the 'Upload Own Website' option.
  4. You will see the 'public_html' folder; upload all the project files except the 'node_modules' folder into it.
  5. After the files are uploaded, go back to the control panel and go to 'Settings' > 'Website' > 'General' and set the 'Web Address' to your domain.
  6. Click 'Save Changes' and your Next.js app should now be published on 000Webhost.


Please note that 000Webhost is a shared hosting platform, and it may not support all the features required by a Next.js app. If you encounter any issues or limitations, you may consider using a different hosting service that supports Node.js applications.