Skip to main content

When to Use the Programmatic API

The Portless programmatic API allows you to embed the proxy server directly into your Node.js application. Use this when:
  • You need custom routing logic beyond hostname-based matching
  • You want to integrate Portless into an existing Node.js tool or framework
  • You need programmatic control over route registration and lifecycle
  • You’re building a development platform that manages multiple services
For most use cases, the CLI is the recommended approach. Only use the programmatic API if you need custom integration.

Installation

Install Portless as a dependency in your project:

Basic Usage

Here’s a minimal example that creates a proxy server and registers a route:

Key Components

The Portless API consists of three main components:

createProxyServer

Create an HTTP/HTTPS proxy server with hostname-based routing

RouteStore

Manage route mappings with file-based persistence

Type Definitions

TypeScript interfaces for routes and configuration

Next Steps

Proxy Server

Learn how to create and configure proxy servers

Route Management

Understand route registration and persistence