Skip to content

Run Web Apps

You can run web applications on your MoltShell VM and preview them in your browser using the built-in port forwarding feature.

Example: Vite project

Create and run a Vite project:

bash
npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev

Vite will start a dev server, typically on port 5173:

  VITE v6.x.x  ready in 300ms

  ➜  Local:   http://localhost:5173/

Now open it in MoltShell:

  1. Click Links in the terminal header
  2. Enter 5173 in the port field
  3. Click Add
  4. Click the external link icon to open the preview in a new tab

Example: Python HTTP server

Serve files from the current directory:

bash
cd ~/my-project
python3 -m http.server 8080

Add port 8080 in the Links panel to preview.

Example: Express.js server

bash
mkdir ~/api-server && cd ~/api-server
npm init -y
npm install express

Create index.js:

javascript
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.json({ message: 'Hello from MoltShell!' });
});

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

Run it:

bash
node index.js

Add port 3000 in the Links panel.

Example: Next.js

bash
npx create-next-app@latest my-next-app
cd my-next-app
npm run dev

Next.js starts on port 3000 by default. Add it in the Links panel.

Tips

  • Port conflicts: If a port is already in use, choose a different one. Many frameworks let you specify the port: npm run dev -- --port 8080 or PORT=8080 node server.js.
  • Host binding: Dev servers that bind to localhost or 127.0.0.1 work fine. The port forwarding proxy connects to localhost on the VM.
  • Hot reload: Vite and similar tools with hot module replacement (HMR) work through port forwarding. The HMR WebSocket connection is forwarded along with HTTP requests.
  • Multiple apps: You can run multiple servers on different ports and add each one to the Links panel.
  • Persistence: Running servers continue even if you close the browser (thanks to tmux). The port forwarding proxy reconnects when you open a new link. However, the Links panel entries are not persisted -- you will need to re-add ports after reopening the terminal.

MoltShell - Your Linux VM in the browser.