Skip to content
Documentation

CLI guide

The Localians CLI

One command turns a local port into a preview link. Everything else is optional.
Beta: Localians is in beta. The localians package is on npm, so there is nothing to install: npx npx localians share 3000 works on Windows PowerShell, macOS and Linux.

Install

You need Node.js 20 or newer. Run the CLI straight from npm, with nothing to install:

$ npx localians share 3000

Or install it once and use the shorter localians command everywhere below:

$ npm install -g localians

The CLI talks to localians.com by default, so no flags are needed. Remove a global install with npm uninstall -g localians. Contributors running their own Localians server can build the CLI from the repository and point it at that server with --api-url <url>.

localians share <port>

Shares the app running on localhost:<port>. Run it in your project folder, in a second terminal next to your dev server.

$ npx localians share 5173
  1. Checks that something is running on that port on your computer.
  2. If this computer isn't signed in yet (or its login expired), opens your browser to approve it, then carries on.
  3. Picks the project: the one you used last time for this app folder and port, else the project that uses this port (it asks you to confirm the first time, and lets you choose if several do). If there isn't one, it asks: create a project named after your app, or use an existing one. It never quietly attaches an app to the wrong project.
  4. Prints your preview link, the workspace and whether the link is public or password protected, and keeps it online until you stop.

Port selection: use the port your dev server prints (Next.js usually 3000, Vite 5173, Angular 4200). Any port from 1 to 65535 works. The CLI only ever forwards to your own computer (127.0.0.1 / ::1).

From the dashboard: the Share App page builds a command like npx localians share 5173 --setup k7m2xq9p4tzw. The one-time code carries the project and access (public or password) you chose there, so the CLI asks nothing. It works once, within 30 minutes, and only for your own login.

Project selection: pass --project <name-or-id> to choose one explicitly, or --new (with an optional --name) to create a new project for this app. The CLI remembers your choice for this folder and port, separately for each account, so next time it just shares. In scripts (no interactive terminal), add --yes to allow creating a project automatically.

$ npx localians share 5173 --project client-dashboard
$ npx localians share 8000 --new --name "Billing API"

Sharing several apps at once

Run one localians share per app, each in its own terminal. Every share gets its own project, link, timer and public or password setting, and runs independently: stopping, reconnecting or losing one never affects the others.

$ npx localians share 3000
$ npx localians share 5173
$ npx localians share 8000

One computer shares each port once: if a port is already being shared from another terminal, the CLI shows that link instead of starting a second one. If that terminal crashed, sharing the port again takes over from it. An account can share up to 5 apps at the same time (the server's limit, configurable by its operator with QUOTA_ACTIVE_PREVIEWS_PER_USER); each project still has its own free preview window or Preview Pass, so more projects never mean more free time for one project.

Preview time: every project gets one free 24-hour preview window, starting with its first share; restarting or reconnecting stays within it. A Preview Pass adds more days for one project. By default a share runs until that window ends — add --duration to stop it sooner.

$ npx localians share 5173 --duration 1h
  • -d, --duration <time> — auto-stop after 5m, 15m, 30m, 1h, 12h or 24h (3d or 7d with a pass).
  • --host-header preserve — send the preview host to your app instead of localhost:<port>.
  • -v, --verbose — print each request and WebSocket.
  • --no-browser — print the sign-in link instead of opening a browser.

Stopping sharing

Press Ctrl+C in the terminal that's sharing, or click Stop Sharing in the dashboard. Either way the link stops working right away. A stopped link is never reused — sharing again gives you a new link.

localians login

Signs this computer in without sharing anything. share does this for you when needed, so you rarely need it. It shows a one-time code and opens your browser to approve it (with --no-browser, open the printed link yourself). The CLI gets its own access token (never your dashboard session): it renews itself while you use it, expires after 90 days unused, and can be revoked any time in Settings → CLI. If you belong to more than one workspace, the approval page asks which one this computer may share into. If you're already signed in, it says which account and changes nothing.

$ npx localians login

localians whoami

Shows which account this computer is signed in to (username, email and workspace), checked with the server.

$ npx localians whoami

localians status

Shows who you're signed in as, and each preview being shared from this computer: project, local address, preview link, status and uptime.

$ npx localians status

localians logout

Revokes this computer's access on the server and deletes it locally. Anything this computer is sharing stops.

$ npx localians logout

Switching accounts: run logout, then login and approve with the other account. Projects remembered for one account are never used for another. If you run a dashboard command (with --setup) that was made by a different account, the CLI says so and offers to switch.

Managing previews in the dashboard

Live Previews lists everything you're sharing with Copy Link, Open Preview and Stop Sharing, and updates as previews connect, drop and reconnect. Request and bandwidth numbers count HTTP requests and WebSocket connections forwarded to your app, and body plus WebSocket data in both directions (headers and encryption overhead aren't counted).

Local development gateway certificates

When the Localians server itself runs on your machine (contributors and beta testers), its gateway uses certificates from a local development CA (npm run tunnel:certs). Trust that CA instead of clicking through warnings, and remove it when you finish. Production previews use publicly trusted certificates and need none of this.

CLI — Windows PowerShell
$ $env:NODE_EXTRA_CA_CERTS = "C:\path\to\localians\.localians-dev\certs\ca.crt"
CLI — macOS / Linux
$ export NODE_EXTRA_CA_CERTS=~/path/to/localians/.localians-dev/certs/ca.crt
Browsers — Windows PowerShell
$ Import-Certificate -FilePath .localians-dev\certs\ca.crt -CertStoreLocation Cert:\CurrentUser\Root
Browsers — macOS
$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain .localians-dev/certs/ca.crt
Browsers — Linux (system, then Chrome/Firefox)
$ sudo cp .localians-dev/certs/ca.crt /usr/local/share/ca-certificates/localians-dev.crt && sudo update-ca-certificates$ certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "Localians dev CA" -i .localians-dev/certs/ca.crt

More help: framework guides, troubleshooting and security.