---
updatedAt: 2026-06-13T01:26:05.000Z
agentTools:
  projectIndex: https://developers.rebrandly.com/llms.txt
---

# Domain aliasing with Node.js/Express

How to serve Rebrandly branded short links from your own Express web server using the rebrandly-express middleware package.

> **Heads up:** This is a technical process that requires access to your server configuration. Test in a staging environment before deploying to production.

You can use a domain from your Express web server for branded short links by setting it up as an alias domain in Rebrandly and installing the `rebrandly-express` package on your server to handle routing.

While this approach works, we recommend using a **dedicated domain** for your branded links whenever possible. A dedicated domain requires no server configuration, has fewer points of failure, and removes the dependency on your website staying correctly configured. See [How do I get a branded domain?](https://support.rebrandly.com/en/articles/469568) if you'd like to take that path instead.

> **Compatibility note:** The `rebrandly-express` package (v0.0.6) has not been updated in several years. It is confirmed working on **Express 4**. Compatibility with **Express 5** (released September 2024) is unconfirmed — test against your Express version in a staging environment before deploying.

## Prerequisites

Before you begin, make sure you have:

* A Rebrandly account
* A domain you own
* An Express 4 web server with Node.js installed
* Access to modify your server code

## Step 1: Add the domain to your Rebrandly account

1. Log in to Rebrandly.
2. Click **Domains**.
3. Click **New Domain**.
4. Click **Connect a domain you already own.**
5. Enter the domain name.
6. Select **No, it's being used for my website**.
7. Click **Use *domain* directly**.
8. Click **Save**.
9. **Copy the alias domain.** Keep this page open—you'll need it for your server configuration.

You can also find the alias domain later from your Domains list by clicking **Server Configuration**.

## Step 2: Install and configure the Rebrandly Express package

Install the `rebrandly-express` npm package:

```bash
npm install rebrandly-express@0.0.6
```

GitHub: <https://github.com/rebrandly/rebrandly-express>

Add the package to your Express application. Replace `your-alias-domain.com` with the alias domain you copied in step 9.

```javascript
const rebrandlyRouter = require("rebrandly-express");

const options = { "alias": "your-alias-domain.com" }; // Replace with your alias domain
const fallbackToRebrandly = rebrandlyRouter(options);

// Initialize your app as usual and add your own middlewares...

// Add Rebrandly right before your catchall rule for 404
app.use(fallbackToRebrandly);
app.use(your404Handler);
```

Restart your Express server.

For detailed configuration options, see the [`rebrandly-express` documentation on GitHub](https://github.com/rebrandly/rebrandly-express).

## Step 3: Test the integration

Create a branded link in Rebrandly using your alias domain, then open the short link in your browser. If everything is configured correctly, it should redirect to your destination URL.

## How it works

The `rebrandly-express` middleware intercepts requests that would normally reach your 404 handler and checks whether a Rebrandly branded link exists for that path. If a matching link is found, the user is redirected to its destination. If no match is found, the request continues to your own 404 handler.

Links created in Rebrandly with an alias domain only activate when the path is not already handled by your website. Your existing routes always take priority.