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

> Learn how to deploy Vite applications on Shard Cloud.

## Introduction

This guide covers deploying Vite-powered applications on Shard Cloud. Vite is a fast build tool that supports React, Vue, Svelte, and vanilla JavaScript.

## Creating Your Project

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

### Creating a New Vite Project

```bash theme={null}
npm create vite@latest my-vite-app
cd my-vite-app
npm install
```

Choose your preferred template: `vanilla`, `vue`, `react`, `svelte`, etc.

## Building Your Project

Build the production output:

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

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

## Serving Your Vite App

Vite outputs static files that need a server:

### Using serve

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

Update `package.json`:

```json package.json theme={null}
{
  "scripts": {
    "build": "vite build",
    "preview": "vite preview",
    "serve": "serve -s dist -l 80"
  }
}
```

### Using Express

Create a `server.js` file:

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

const app = express();

app.use(express.static(path.join(__dirname, 'dist')));

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

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

## Shard Cloud Configuration

Create a `.shardcloud` file:

```systemd .shardcloud theme={null}
DISPLAY_NAME=Vite App
DESCRIPTION=Vite-powered Application
LANGUAGE=node
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-vite-app
CUSTOM_COMMAND=npm run build && npx serve -s dist -l 80
```

## Deploying

<Steps>
  <Step title="Build Your Application">
    Run `npm run build` to generate the `dist` folder.
  </Step>

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

    * Source files
    * `package.json`
    * `.shardcloud`
    * `vite.config.js`
  </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 Vite documentation](https://vitejs.dev/) for more information.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Build fails">
    * Check for syntax errors in your code
    * Verify all imports are correct
  </Accordion>

  <Accordion title="Assets not loading">
    Check your `base` configuration in `vite.config.js` if using a subdirectory.
  </Accordion>
</AccordionGroup>
