LinuxCommandLibrary

live-server

Serve static web pages for development

TLDR

Serve an index.html file and reload on changes

$ live-server
copy

Specify a port (default is 8080) from which to serve a file
$ live-server --port=[8081]
copy

Specify a given file to serve
$ live-server --open=[about.html]
copy

Proxy all requests for ROUTE to URL
$ live-server --proxy=[/]:[http:localhost:3000]
copy

SYNOPSIS

live-server [path] [options]

PARAMETERS

path
    The directory to serve. If omitted, it defaults to the current directory.

--port=
    Specify the port to listen on (default: 8080).

--host=
    Specify the host to listen on (default: 127.0.0.1).

--no-browser
    Prevent the browser from automatically opening.

--browser=
    Specify which browser to open (e.g., 'chrome', 'firefox', 'safari').

--index=
    Specify the index file (default: index.html).

--mount=
    Mount a specific directory to a route (e.g., '/api:./data').

--wait=
    Wait time (in milliseconds) before reloading the browser after a file change (default: 100ms).

--open=
    Specify a path to open in the browser after starting the server (e.g., '/mypage.html').

--https
    Serve over HTTPS (requires certificates).

--cert=
    Path to the SSL certificate file (when using HTTPS).

--key=
    Path to the SSL key file (when using HTTPS).

--proxy=
    Proxy requests to another server. Example: --proxy /api:http://localhost:3000.

--middleware=
    Path to a javascript module with custom middleware.

DESCRIPTION

live-server is a lightweight, zero-configuration HTTP server that's primarily designed for rapid prototyping and development of web applications.
It's particularly useful for serving static HTML, CSS, and JavaScript files during development. It automatically refreshes the browser whenever it detects changes to the served files, greatly speeding up the development workflow.
It simplifies local web development by eliminating the need for manually configuring a web server or dealing with complex build processes for simple projects. It's intended for development purposes only and is not suitable for production environments.

CAVEATS

live-server is intended for development purposes and isn't suitable for production use. It lacks security features and performance optimizations necessary for a production environment. Also, heavy usage of --wait could impact in performance.

<B>USAGE EXAMPLE</B>

To start the server in the current directory: live-server.
To serve a specific directory: live-server myproject.
To specify a different port: live-server --port=3000.

HISTORY

live-server gained popularity as a simple and efficient solution for quickly serving web content during development. Its ease of use and automatic browser reloading made it a favorite among front-end developers. It's evolved over time to include features like HTTPS support and proxying, further enhancing its utility in development workflows.

SEE ALSO

python3 -m http.server(1), tac(1)

Copied to clipboard