---
lang: en
title: 'API docs: rest.restapplication.expressmiddleware'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.restapplication.expressmiddleware.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [RestApplication](./rest.restapplication.md) &gt; [expressMiddleware](./rest.restapplication.expressmiddleware.md)

## RestApplication.expressMiddleware() method

Bind an Express middleware to this server context

**Signature:**

```typescript
expressMiddleware(key: BindingAddress, middleware: ExpressRequestHandler | ExpressRequestHandler[], options?: MiddlewareBindingOptions): Binding<Middleware>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  key | [BindingAddress](./context.bindingaddress.md) | Middleware binding key |
|  middleware | ExpressRequestHandler \| ExpressRequestHandler\[\] | Express middleware handler function(s) |
|  options | MiddlewareBindingOptions | _(Optional)_ |

**Returns:**

[Binding](./context.binding.md)<!-- -->&lt;Middleware&gt;

## Example


```ts
import myExpressMiddlewareFactory from 'my-express-middleware';
const myExpressMiddlewareConfig= {};
const myExpressMiddleware = myExpressMiddlewareFactory(myExpressMiddlewareConfig);
server.expressMiddleware('middleware.express.my', myExpressMiddleware);
```


