> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.squarecloud.app/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to host an Astro site

# How to Host Astro Applications on Square Cloud

Astro is known for its "islands" architecture and for generating extremely fast websites. On Square Cloud, you can host static websites or Astro applications with SSR (Server-Side Rendering). For the default static site model, we will use the **serve** library to handle requests on port 80.

---

## 1. The Build Process

Before deploying your files to Square Cloud, you need to generate the production version of your website. Astro compiles your components and content into optimized HTML, CSS, and JS files.

In your local terminal, run:
```bash
npm run build
```
This command will create a folder named **`dist/`** at the root of your project. This folder contains everything your end user will see.

---

## 2. Preparing the File Server

Since Astro (in static mode) only generates files, we need a small server to "serve" these files via HTTP. The **serve** library is the recommended choice due to its simplicity.

In your `package.json` file, add the dependency:
```json
"dependencies": {
  "serve": "^14.0.0"
}
```

---

## 3. Configuring the Port and Start

Square Cloud makes **port 80** available for your application to use and receive requests. The initialization command must be configured to point the server to the build folder and set the correct port.

**Start Command:**
```bash
npx serve dist -p 80
```

*   **`dist`**: Indicates the folder where the compiled files are located.
*   **`-p 80`**: Sets the mandatory port for traffic on Square Cloud.

---

## 4. Deployment File Structure (.zip)

To upload, create a compressed file containing only the essentials for execution:

*   The **`dist/`** folder (Generated by the build).
*   The **`package.json`** file.

**Tip:** Do not include the `node_modules` or `src` folder. Square Cloud will automatically install the necessary dependencies.

---

## 5. Astro with SSR (Optional)

If you are using Astro with an adapter (such as Node.js) for server-side rendering (SSR), the process changes slightly:
1.  The build command is still required.
2.  The start command will usually be `node ./dist/server/entry.mjs` (or similar, depending on your adapter).