- Use Ngrok to create a secure tunnel to your applications.
- Manually define the tunnel settings.
- Alternatively, let Ngrok wrap your existing targets to automatically read the server URL.
- Generate a new Ngrok tunnel target for your existing apps.
Using pnpm:
pnpm add -D nx-ngrok
Using npm
npm install -D nx-ngrok
Using yarn
yarn add -D nx-ngrok
Before you can serve HTML content, Ngrok requires you to sign up for a free ngrok account to get an authtoken.
It is recommended to follow Ngrok's documentation and install your authtoken.
Alternatively, you can set the authtoken via an Environment Variable or as an option in each executor.
Warning
Keep your authtoken private and safe. Do not commit it to git!
NGROK_AUTHTOKEN
- Specifies the authentication token (authtoken) used to connect to the ngrok service.
Start a new Ngrok tunnel.
"targets": {
"dev": {
"executor": "nx-ngrok:tunnel",
"options": {
"target": "examples-nextjs:serve",
},
},
}
tunnel executor options
Name | Type | Required | Default | Description |
---|---|---|---|---|
target |
string |
- | - | Server target to run tunnel for. |
protocol |
http , tcp , tls |
- | http |
The tunnel protocol name. This defines the type of tunnel you would like to start. |
address |
string , number |
- | - | Forward traffic to this local port number or network address. |
auth |
string |
- | - | HTTP Basic authentication for tunnel. |
port |
targetDefault , auto , number |
- | targetDefault |
Override the target's port number — only supported if the target accepts a port setting. |
subdomain |
string |
- | - | Subdomain name to request. If unspecified, ngrok provides a unique subdomain based on your account type. |
authToken |
string |
- | - | Specifies the authentication token (authtoken) used to connect to the ngrok service. |
region |
us , eu , au , ap , sa , jp , in |
- | us |
Choose the region where the ngrok agent will connect to host its tunnels. |
ngrokConfig |
string |
- | - | Custom path for ngrok config file. |
Generate a target to run a Ngrok tunnel for a local server.
nx generate nx-grok:tunnel dev --project=my-app --target=serve
tunnel generator output
> NX Generating nx-ngrok:tunnel
UPDATE apps/my-app/project.json
tunnel generator options
Name | Alias | Type | Required | Default | Description |
---|---|---|---|---|---|
name |
- | string |
✅ | - | Target name. |
project |
- | string |
✅ | - | What project does the target belong to? |
target |
- | string |
- | - | Server target to run tunnel for. |
port |
targetDefault , auto , number |
- | targetDefault |
Override the target's port number — only supported if the target accepts a port setting. | |
protocol |
- | http , tcp , tls |
- | http |
The tunnel protocol name. This defines the type of tunnel you would like to start. |
address |
- | string , number |
- | - | Forward traffic to this local port number or network address. |
auth |
- | string |
- | - | HTTP Basic authentication for tunnel. |
subdomain |
- | string |
- | - | Subdomain name to request. If unspecified, ngrok provides a unique subdomain based on your account type. |
region |
- | us , eu , au , ap , sa , jp , in |
- | us |
Choose the region where the ngrok agent will connect to host its tunnels. |
Name | Path |
---|---|
nest | examples/nest |
nextjs | examples/nextjs |
nx-mesh | examples/nx-mesh-app |
nx-ngrok |
Nx |
---|---|
^1.0.0 |
^15.7.1 |
This plugin wouldn't be possible without the great teams behind these projects:
- Ngrok - A simplified API-first ingress-as-a-service that adds connectivity, security, and observability to your apps in one line
- Ngrok Node API - A Node wrapper for Ngrok's API.
- Nrwl - The team behind Nx
Please show them your support! ❤️
🌳 🦌 🌳