Skip to main content

ngrok JavaScript SDK Quickstart

The ngrok JavaScript (Node.js) SDK is an open-source package that enables you to quickly and efficiently serve Node.js applications on the internet without the need to configure low-level network primitives like IPs, certificates, load balancers, or ports. You can think of it as the ngrok Agent CLI packaged as a JS library.

This quickstart uses the ngrok JavaScript SDK to create an agent endpoint that forwards traffic from the internet to a Node.js app running on your local device, then secure it by requiring visitors to log in with a Google account to access it.

What you'll need

1. Reserve your domain

A new URL is generated for you every time you start an endpoint. To maintain a consistent URL, you can reserve a free static domain connected to your ngrok account.

Navigate to the dashboard, visit the Domains section, and select + New Domain. You can choose a free static domain, or you can use a custom domain you already own.

2. Start your app or service

Start up the app or service you'd like to put online. This is the app that your agent endpoint will forward online traffic to.

If you don't have an app to work with, you can create a minimal Node.js app using the following code to set up a basic HTTP server at port 8080.

Loading…

Navigate to the directory where this file is located and run the following command to start the server:

Loading…

3. Install the JavaScript SDK