|
1 | 1 | --- |
2 | 2 | title: Self-host |
3 | | -lastModified: "2026-03-10" |
| 3 | +lastModified: "2026-04-06" |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | <Info type="danger"> |
@@ -78,13 +78,105 @@ You can also open Prisma Studio to see the database interface and edit data dire |
78 | 78 |
|
79 | 79 | <PlatformCodeblock document="others/self-host" examples={["prisma-studio"]} hidePlatformSelector /> |
80 | 80 |
|
| 81 | +## QEMU Local Emulator |
| 82 | + |
| 83 | +The QEMU local emulator packages the entire Stack Auth backend into a single virtual machine image. It bundles PostgreSQL, Redis, ClickHouse, MinIO, Inbucket, Svix, QStash, and the Stack Auth dashboard and backend—everything you need for local development without setting up individual services. |
| 84 | + |
| 85 | +### Prerequisites |
| 86 | + |
| 87 | +Before using the emulator, make sure you have: |
| 88 | + |
| 89 | +- **QEMU** installed on your system (for running the virtual machine) |
| 90 | +- **GitHub CLI** (`gh`) installed and authenticated (for downloading emulator images) |
| 91 | + |
| 92 | +On macOS, install with Homebrew: |
| 93 | + |
| 94 | +```bash |
| 95 | +brew install qemu gh |
| 96 | +``` |
| 97 | + |
| 98 | +On Linux (Debian/Ubuntu): |
| 99 | + |
| 100 | +```bash |
| 101 | +sudo apt install qemu-system gh |
| 102 | +``` |
| 103 | + |
| 104 | +### Getting Started |
| 105 | + |
| 106 | +Pull the latest emulator image and start it: |
| 107 | + |
| 108 | +<PlatformCodeblock document="others/self-host" examples={["emulator-install"]} hidePlatformSelector /> |
| 109 | + |
| 110 | +<PlatformCodeblock document="others/self-host" examples={["emulator-start"]} hidePlatformSelector /> |
| 111 | + |
| 112 | +The emulator automatically downloads the latest image if none exists locally. On first start, it may take a minute to boot. Subsequent starts are faster due to snapshot caching. |
| 113 | + |
| 114 | +### Emulator Commands |
| 115 | + |
| 116 | +The Stack CLI provides commands to manage the emulator: |
| 117 | + |
| 118 | +| Command | Description | |
| 119 | +|---------|-------------| |
| 120 | +| `emulator pull` | Download the latest emulator image | |
| 121 | +| `emulator start` | Start the emulator (auto-pulls if needed) | |
| 122 | +| `emulator stop` | Stop the emulator (preserves data) | |
| 123 | +| `emulator reset` | Wipe all data and reset to a fresh state | |
| 124 | +| `emulator status` | Show emulator and service health | |
| 125 | +| `emulator list-releases` | List available emulator releases | |
| 126 | + |
| 127 | +### Bundled Services |
| 128 | + |
| 129 | +The emulator runs these services inside the virtual machine: |
| 130 | + |
| 131 | +| Service | Host Port | Description | |
| 132 | +|---------|-----------|-------------| |
| 133 | +| Dashboard | 26700 | Stack Auth dashboard UI | |
| 134 | +| Backend | 26701 | Stack Auth API server | |
| 135 | +| MinIO | 26702 | S3-compatible storage | |
| 136 | +| Inbucket | 26703 | Email testing interface | |
| 137 | + |
| 138 | +PostgreSQL, Redis, ClickHouse, Svix, and QStash run internally and are not exposed to the host. |
| 139 | + |
| 140 | +### Using the Emulator with Your App |
| 141 | + |
| 142 | +Once the emulator is running, configure your app to connect to the local backend: |
| 143 | + |
| 144 | +``` |
| 145 | +NEXT_PUBLIC_STACK_API_URL=http://localhost:26701 |
| 146 | +``` |
| 147 | + |
| 148 | +Open the dashboard at [http://localhost:26700](http://localhost:26700) to create projects and manage users. Check Inbucket at [http://localhost:26703](http://localhost:26703) to view test emails. |
| 149 | + |
| 150 | +### Hardware Acceleration |
| 151 | + |
| 152 | +The emulator uses hardware acceleration when available: |
| 153 | +- **macOS**: Uses HVF (Hypervisor.framework) for native architecture |
| 154 | +- **Linux**: Uses KVM when available |
| 155 | +- **Cross-architecture**: Falls back to software emulation (slower) |
| 156 | + |
| 157 | +For best performance, run the emulator on your native architecture (arm64 on Apple Silicon, amd64 on Intel/AMD). |
| 158 | + |
| 159 | +### Managing Emulator Data |
| 160 | + |
| 161 | +To stop the emulator while preserving your data: |
| 162 | + |
| 163 | +<PlatformCodeblock document="others/self-host" examples={["emulator-stop"]} hidePlatformSelector /> |
| 164 | + |
| 165 | +To check the status of the emulator and its services: |
| 166 | + |
| 167 | +<PlatformCodeblock document="others/self-host" examples={["emulator-status"]} hidePlatformSelector /> |
| 168 | + |
| 169 | +To wipe all data and start fresh: |
| 170 | + |
| 171 | +<PlatformCodeblock document="others/self-host" examples={["emulator-reset"]} hidePlatformSelector /> |
| 172 | + |
81 | 173 | ## Local Emulator Mode |
82 | 174 |
|
83 | | -**Local emulator mode** lets you map projects to local config files during development, instead of creating them through the dashboard. |
| 175 | +**Local emulator mode** lets you map projects to local config files during development, instead of creating them through the dashboard. This is automatically enabled when using the QEMU emulator. |
84 | 176 |
|
85 | 177 | ### Enabling Local Emulator Mode |
86 | 178 |
|
87 | | -Set this environment variable in both your backend and dashboard `.env` files: |
| 179 | +If you're running the QEMU emulator, local emulator mode is enabled by default. For manual setups, set this environment variable in both your backend and dashboard `.env` files: |
88 | 180 |
|
89 | 181 | ``` |
90 | 182 | NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR=true |
|
0 commit comments