# @salesforce/mrt-utilities

> Middleware and utilities to simulate a deployed Managed Runtime environment

Latest version **0.3.1** (published 2026-08-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @salesforce/mrt-utilities
pnpm add @salesforce/mrt-utilities
yarn add @salesforce/mrt-utilities
bun add @salesforce/mrt-utilities
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2026-08-25 |
| First published | 2026-03-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.16.0 |
| Dependencies | 11 |
| Unpacked size | 443.5 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 53 |
| Author | Salesforce |
| Maintainers | ire-npm-team-user, jimjag, salesforce-releases, jasonschroeder-sfdc, mobify, lwc-admin, salesforce-admin |
| Keywords | salesforce, commerce-cloud, mrt, middleware, express |

## Links

- npm: https://www.npmjs.com/package/@salesforce/mrt-utilities
- Repository: https://github.com/SalesforceCommerceCloud/b2c-developer-tooling
- Homepage: https://github.com/SalesforceCommerceCloud/b2c-developer-tooling#readme
- Issues: https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/issues
- npm.io page: https://npm.io/package/@salesforce/mrt-utilities

## Dependencies (11)

- [qs](https://npm.io/package/qs.md) 6.15.2
- [mime-types](https://npm.io/package/mime-types.md) 3.0.1
- [negotiator](https://npm.io/package/negotiator.md) 1.0.0
- [change-case](https://npm.io/package/change-case.md) 5.4.4
- [compressible](https://npm.io/package/compressible.md) 2.0.18
- [set-cookie-parser](https://npm.io/package/set-cookie-parser.md) 2.7.1
- [@aws-sdk/lib-dynamodb](https://npm.io/package/@aws-sdk/lib-dynamodb.md) 3.1049.0
- [http-proxy-middleware](https://npm.io/package/http-proxy-middleware.md) 3.0.5
- [@aws-sdk/client-dynamodb](https://npm.io/package/@aws-sdk/client-dynamodb.md) 3.1049.0
- [@h4ad/serverless-adapter](https://npm.io/package/@h4ad/serverless-adapter.md) 4.4.0
- [@aws-sdk/client-cloudwatch](https://npm.io/package/@aws-sdk/client-cloudwatch.md) 3.1049.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2026-08-25
- 0.0.0-nightly.20260918022552 (nightly) — 2026-09-18
- 0.0.0-nightly.20260917022501 — 2026-09-17
- 0.0.0-nightly.20260916022450 — 2026-09-16
- 0.0.0-nightly.20260915022546 — 2026-09-15
- 0.0.0-nightly.20260914022841 — 2026-09-14
- 0.0.0-nightly.20260912012643 — 2026-09-12
- 0.0.0-nightly.20260911022520 — 2026-09-11
- 0.0.0-nightly.20260910022524 — 2026-09-10
- 0.0.0-nightly.20260909022432 — 2026-09-09
- 0.0.0-nightly.20260908174019 — 2026-09-08
- 0.0.0-nightly.20260908022430 — 2026-09-08
- 0.0.0-nightly.20260907022646 — 2026-09-07
- 0.0.0-nightly.20260904022518 — 2026-09-04
- 0.0.0-nightly.20260903030411 — 2026-09-03
- … 139 more at https://npm.io/package/@salesforce/mrt-utilities/versions

## README

# mrt-utilities

Middleware and utilities to simulate a deployed MRT environment.

## Usage

```
import {
    createMRTProxyMiddlewares,
    createMRTRequestProcessorMiddleware,
    createMRTStaticAssetServingMiddleware,
    createMRTCommonMiddleware,
    createMRTCleanUpMiddleware,
    isLocal,
} from '@salesforce/mrt-utilities';


export const createApp = (): Express => {
    const app = express();
    app.disable('x-powered-by');

    // Top most middleware to set up headers
    app.use(createMRTCommonMiddleware());

    if (isLocal()) {
        const requestProcessorPath = 'path/to/request-processor.js';
        const proxyConfigs = [
            {
                host: 'https://example.com',
                path: 'api',
            },
        ];
        app.use(createMRTRequestProcessorMiddleware(requestProcessorPath, proxyConfigs));

        const mrtProxies = createMRTProxyMiddlewares(proxyConfigs);
        mrtProxies.forEach(({ path, fn }) => {
            app.use(path, fn);
        });

        const staticAssetDir = 'path/to/static';
        app.use(
            `/mobify/bundle/${process.env.BUNDLE_ID || '1'}/static/`,
            createMRTStaticAssetServingMiddleware(staticAssetDir)
        );
    }

    // Cleans up any remaining headers and sets any remaining values
    app.use(createMRTCleanUpMiddleware());
```

## Development data-store usage

Use the `data-store` subpath with Node's `dev-data-store` condition to load the pseudo local data-store implementation:

```bash
node --conditions dev-data-store your-app.js
```

```ts
import {DataStore} from '@salesforce/mrt-utilities/data-store';

const store = DataStore.getDataStore();
const entry = await store.getEntry('custom-global-preferences');
```

Configure local values with environment variables:

- `MRT_DATA_STORE_DEFAULTS`: JSON map of key to object value
- `MRT_DATA_STORE_WARN_ON_MISSING`: set to `false` to suppress missing-key warnings

Example:

```bash
export MRT_DATA_STORE_DEFAULTS='{"custom-global-preferences":{"featureFlag":true}}'
export MRT_DATA_STORE_WARN_ON_MISSING=true
```

By default, missing keys still throw `DataStoreNotFoundError` in development (matching production semantics).

---
_Source: https://npm.io/package/@salesforce/mrt-utilities · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
