---
description: Build, package, and deploy frontend updates via OTA
---

This workflow automates the process of building the frontend, packaging it into a LittleFS binary, and uploading it to the ESP32 device.

> [!IMPORTANT]
> Ensure `VITE_API_BASE` in `frontend/.env` is set to the target device's IP address.

### Steps

1. **Build and Package Frontend**
   Run the following command in the `frontend/` directory to build the production assets and create the versioned `.bin` file:
   ```bash
   npm run build:esp32 && npm run ota:package
   ```

2. **Deploy Update**
   Run the deployment script to upload the latest version to the device:
   ```bash
   npm run ota:deploy
   ```

3. **Verify Update**
   Wait for the device to reboot and verify the changes on the dashboard.

---

### Universal Bundle Option

If you also need to update the firmware, use the universal bundle workflow:

1. **Build Firmware**
   From the project root:
   ```bash
   idf.py build
   ```

2. **Create Bundle**
   In the `frontend/` directory:
   ```bash
   npm run ota:bundle
   ```

3. **Deploy Bundle**
   In the `frontend/` directory:
   ```bash
   npm run ota:deploy-bundle
   ```
