listhen is an elegant HTTP listener for Node.js, designed to streamline local development server setups. It supports various server handlers including Node.js built-in HTTP, Express, and `unjs/h3`, making it highly adaptable for different project types. Currently at version 1.9.1, the package maintains an active release cadence, frequently publishing minor improvements and bug fixes, as evidenced by recent releases such as v1.9.1, v1.9.0, and v1.8.0. Key differentiators include its rich feature set out-of-the-box, such as hot module reloading (HMR) capabilities, static file serving, robust TypeScript support via `unjs/jiti`, and integrated WebSocket support through `unjs/crossws`. It also enhances developer experience with features like automatic port finding (via `get-port-please`), displaying QR codes for public URLs (with `unjs/uqr`), local server tunneling (using `unjs/untun`), clipboard integration for URLs, and simplified HTTPS setup with self-signed certificates. listhen aims to provide a comprehensive, zero-configuration development server experience, abstracting away common setup complexities.
npm install listhenVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create an h3 application and listen to it using `listhen`, showcasing essential options like port, hostname, URL clipboard copying, and automatic browser opening.
If you require these features in a non-development environment, you must explicitly set `isTest: false` and `isProduction: false` in the options object, though this is generally not recommended.
For development, accept the browser warning. For production or trusted environments, provide your own trusted SSL certificates using the `https: { cert, key }` option.Set `hostname: 'localhost'` or `hostname: '127.0.0.1'` in your `listhen` options to restrict access to the local machine.
Specify a different port number in the `port` option, or omit the `port` option entirely to allow `listhen` to automatically find an available port using `get-port-please`.
Ensure your project is configured for ES Modules (add `"type": "module"` to your `package.json` file) and use `import` statements. If you must use CommonJS, verify the package version is fully compatible with CommonJS or consider using a bundler like Webpack/Rollup that handles module interoperability.
For development, bypass the browser security warning. For production, acquire and configure a valid, trusted SSL certificate by providing `cert` and `key` paths in the `https` option: `{ https: { cert: 'path/to/cert.pem', key: 'path/to/key.pem' } }`.No dependency data recorded yet.