> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shardcloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Host Express Applications

> Learn how to create and deploy Express.js applications on Shard Cloud.

## Introduction

This guide covers deploying Express.js applications on Shard Cloud, from initial setup to production deployment.

## Creating Your Project

Before starting, ensure you have **Node.js** and **npm** installed. Download from the [official Node.js website](https://nodejs.org/).

### Installing Express

```bash theme={null}
npm init -y
npm install express
```

### Basic Express Application

Create an `index.js` file:

```javascript index.js theme={null}
import express from "express";

const app = express();
const port = 80;

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(port, () => {
  console.log(`Express app listening on port ${port}`);
});
```

<Note>Port 80 is required for web applications on Shard Cloud.</Note>

### Package.json Configuration

```json package.json theme={null}
{
  "name": "my-express-app",
  "version": "1.0.0",
  "type": "module",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "express": "^4.18.0"
  }
}
```

## Shard Cloud Configuration

Create a `.shardcloud` file in your project root:

```systemd .shardcloud theme={null}
DISPLAY_NAME=My Express API
DESCRIPTION=Express.js REST API
MAIN=index.js
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-express-api
```

## Deploying

<Steps>
  <Step title="Prepare Your Files">
    Ensure you have: - `index.js` (or your entry file) - `package.json` -
    `.shardcloud`
  </Step>

  <Step title="Exclude Unnecessary Files">
    Remove before zipping: - `node_modules/` - `package-lock.json`
  </Step>

  <Step title="Create ZIP Archive">
    Compress your project folder into a `.zip` file.
  </Step>

  <Step title="Upload to Shard Cloud">
    Go to [Shard Cloud Dashboard](https://shardcloud.app/dash/applications) and
    click **"New app"** to upload your project.
  </Step>
</Steps>

## Additional Resources

For more information about Express, visit the [official Express documentation](https://expressjs.com/).

## Troubleshooting

<AccordionGroup>
  <Accordion title="Application won't start">
    * Verify your `MAIN` file path is correct - Check that port 80 is used for
      web applications - Ensure all dependencies are in `package.json`
  </Accordion>

  <Accordion title="Cannot connect to application">
    * Confirm `SUBDOMAIN` is set in `.shardcloud` - Wait a few moments after
      deployment for DNS propagation
  </Accordion>
</AccordionGroup>
