> ## 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 Astro Applications

> Learn how to deploy Astro applications on Shard Cloud.

## Introduction

This guide covers deploying Astro applications on Shard Cloud. Astro is a modern static site generator with optional server-side rendering.

## Creating Your Project

Ensure you have **Node.js** (16+) and **npm** installed.

### Creating a New Astro Project

```bash theme={null}
npm create astro@latest
cd my-astro-site
npm install
```

## Building Your Project

Build the production output:

```bash theme={null}
npm run build
```

This creates a `dist/` folder with static files.

## Serving Your Astro Site

### Static Sites (Default)

For static Astro sites, use serve:

```systemd .shardcloud theme={null}
DISPLAY_NAME=Astro Site
DESCRIPTION=Astro Static Site
LANGUAGE=node
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-astro-site
CUSTOM_COMMAND=npm run build && npx serve -s dist -l 80
```

### SSR Mode

For server-side rendering with Node.js adapter:

1. Install the Node adapter:

```bash theme={null}
npx astro add node
```

2. Configure `astro.config.mjs`:

```javascript astro.config.mjs theme={null}
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: node({
    mode: 'standalone'
  }),
  server: {
    port: 80,
    host: true
  }
});
```

3. Shard Cloud config:

```systemd .shardcloud theme={null}
DISPLAY_NAME=Astro SSR Site
DESCRIPTION=Astro Server-Rendered Site
LANGUAGE=node
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-astro-ssr
CUSTOM_COMMAND=npm run build && node dist/server/entry.mjs
```

## Deploying

<Steps>
  <Step title="Build Your Application">
    Run `npm run build`.
  </Step>

  <Step title="Prepare Your Files">
    Ensure you have:

    * `src/` folder
    * `package.json`
    * `.shardcloud`
    * `astro.config.mjs`
  </Step>

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

  <Step title="Create ZIP Archive">
    Compress your project folder.
  </Step>

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

## Additional Resources

Visit the [official Astro documentation](https://docs.astro.build/) for more information.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Build errors">
    Check for component syntax errors and ensure all dependencies are installed.
  </Accordion>

  <Accordion title="SSR not working">
    Verify the Node adapter is properly configured and the output mode is set to 'server'.
  </Accordion>
</AccordionGroup>
