---
lang: en
title: 'API docs: rest.restapplication.expressmiddleware_1'
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_1.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_1.md)

## RestApplication.expressMiddleware() method

Bind an Express middleware to this server context

**Signature:**

```typescript
expressMiddleware<CFG>(middlewareFactory: ExpressMiddlewareFactory<CFG>, middlewareConfig?: CFG, options?: MiddlewareBindingOptions): Binding<Middleware>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  middlewareFactory | ExpressMiddlewareFactory&lt;CFG&gt; | Middleware module name or factory function |
|  middlewareConfig | CFG | _(Optional)_ Middleware config |
|  options | MiddlewareBindingOptions | _(Optional)_ Options for registration |

**Returns:**

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

## Example


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


