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

> Learn how to deploy Angular applications on Shard Cloud.

## Introduction

This guide covers deploying Angular applications on Shard Cloud.

## Creating Your Project

Ensure you have **Node.js** and **npm** installed.

### Installing Angular CLI

```bash theme={null}
npm install -g @angular/cli
```

### Creating a New Project

```bash theme={null}
ng new my-angular-app
cd my-angular-app
```

## Building Your Project

Build the production output:

```bash theme={null}
ng build --configuration production
```

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

## Serving Your Angular App

Angular apps are static files that need a server:

### Using serve

```bash theme={null}
npm install serve
```

### Using Express

Create a `server.js` file:

```javascript server.js theme={null}
const express = require('express');
const path = require('path');

const app = express();
const distPath = path.join(__dirname, 'dist', 'my-angular-app', 'browser');

app.use(express.static(distPath));

app.get('*', (req, res) => {
  res.sendFile(path.join(distPath, 'index.html'));
});

app.listen(80, () => {
  console.log('Server running on port 80');
});
```

<Note>
  Replace `my-angular-app` with your actual project name in the path.
</Note>

## Shard Cloud Configuration

Create a `.shardcloud` file:

```systemd .shardcloud theme={null}
DISPLAY_NAME=Angular App
DESCRIPTION=Angular Application
LANGUAGE=node
MEMORY=1024
VERSION=recommended
SUBDOMAIN=my-angular-app
CUSTOM_COMMAND=npm run build && npx serve -s dist/my-angular-app/browser -l 80
```

## Deploying

<Steps>
  <Step title="Build Your Application">
    Run `ng build --configuration production`.
  </Step>

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

    * Source files
    * `package.json`
    * `.shardcloud`
    * `angular.json`
  </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 Angular documentation](https://angular.dev/) for more information.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Build fails with memory errors">
    Increase `MEMORY` to at least 1024MB for Angular builds.
  </Accordion>

  <Accordion title="Routes not working (404)">
    Ensure your server serves `index.html` for all routes.
  </Accordion>
</AccordionGroup>
