> ## 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 a SolidJS application

# How to Host SolidJS Applications on Square Cloud

Hosting SolidJS on Square Cloud is simple and extremely efficient. Depending on your project's architecture, you will either follow the path of a static deployment or a high-performance Vinxi server.

---

## 1. Build

If you are using standard SolidJS managed by Vite, your application generates static files that need to be "served" by a lightweight Node.js process.

### Step 1: Production Build
In your local terminal, run:
```bash
npm run build
```
This will generate the **`dist/`** folder at the root of your project.

## 2. Configuring the Port and Start Command

Square Cloud makes **port 80** available for your application to use and receive requests. If you are using **SolidStart**, it uses **Vinxi** as its infrastructure engine.
In this case, the application runs a real server that enables server-side rendering (SSR).

### Startup Command
Generally, SolidStart generates an output that can be started via Node.js or through the Vinxi CLI itself:
```bash
npx vinxi start --port 80
```
*(Make sure your&#32;`start`&#32;script in package.json already points to the correct execution on port 80).*

---

## 3. Preparing the Deployment (.zip)

To ensure that the deployment is fast and error-free, your `.zip` file should contain only the essentials:

*   **For Vite:** See [here](https://help.squarecloud.app/pt-br/article/como-fazer-deploy-de-um-site-estatico-html-react-vite-142t186).
*   **For SolidStart/Vinxi:** The `.output/` (or `dist/`) folder, `package.json`, and `package-lock.json`.

> **Tip:** Never upload the `node_modules` folder. Square Cloud will perform a clean installation of dependencies on the server.

---

## 4. Environment Variables (ENV)

If your SolidJS app consumes APIs or has private keys:
1.  Go to the **Square Cloud Dashboard**.
2.  On your application's tab, access **Environment Variables**.
3.  Configure keys like `API_URL` or `DB_AUTH` there. In SolidJS, remember that variables exposed to the client in Vite must start with `VITE_`.

---

## 5. Performance Tips

*   **Hydration:** If you are using SSR with SolidStart, monitor memory usage. SolidJS is highly efficient, but the server hydration process consumes resources during traffic spikes.
*   **Cache:** Use Square Cloud's caching for static assets (images, CSS) to decrease the initial loading time (LCP).