# @routup/query

> Query plugin for routup.

Latest version **4.0.1** (published 2026-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @routup/query
pnpm add @routup/query
yarn add @routup/query
bun add @routup/query
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-10-13 |
| First published | 2022-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Peter Placzek |
| Maintainers | tada5hi |
| Keywords | query, query-string, query-parse, parse, api, rest, http, router, api-router, route, routing |

## Links

- npm: https://www.npmjs.com/package/@routup/query
- Repository: https://github.com/routup/plugins
- Homepage: https://github.com/routup/plugins#readme
- Issues: https://github.com/routup/plugins/issues
- npm.io page: https://npm.io/package/@routup/query

## Dependencies (2)

- [qs](https://npm.io/package/qs.md) ^6.15.3
- [@types/qs](https://npm.io/package/@types/qs.md) ^6.15.1

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2026-10-13
- 4.0.0 — 2026-05-20
- 3.2.0 — 2026-05-12
- 3.1.0 — 2026-05-06
- 3.0.0 — 2026-05-05
- 2.4.3 — 2025-11-26
- 2.4.2 — 2025-06-25
- 2.4.1 — 2024-09-15
- 2.4.0 — 2024-06-29
- 2.3.2 — 2024-04-04
- 2.3.1 — 2024-01-10
- 2.3.0 — 2023-11-21
- 2.2.0 — 2023-11-20
- 2.1.0 — 2023-10-22
- 2.0.0 — 2023-10-04
- … 36 more at https://npm.io/package/@routup/query/versions

## README

# @routup/query

[![npm version](https://badge.fury.io/js/@routup%2Fquery.svg)](https://badge.fury.io/js/@routup%2Fquery)
[![main](https://github.com/routup/plugins/actions/workflows/main.yml/badge.svg)](https://github.com/routup/plugins/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/routup/plugins/branch/master/graph/badge.svg)](https://codecov.io/gh/routup/plugins)
[![Known Vulnerabilities](https://snyk.io/test/github/routup/plugins/badge.svg)](https://snyk.io/test/github/routup/plugins)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)

This is a plugin for reading and parsing the query string of the request url.

**Table of Contents**

- [Installation](#installation)
- [Documentation](#documentation)
- [Usage](#usage)
- [Helpers](#helpers)
  - [setRequestQuery](#setrequestquery)
  - [useRequestQuery](#userequestquery)
- [License](#license)

## Installation

```bash
npm install @routup/query --save
```

## Documentation

To read the docs, visit [https://routup.net](https://routup.net)

## Usage

It is important to invoke the request middleware,
to parse the query-string of the request url.

```typescript
import {
    App,
    defineCoreHandler,
    serve,
} from 'routup';
import {
    query,
    useRequestQuery
} from '@routup/query';

const router = new App();

router.use(query());

router.get('/', defineCoreHandler((event) => {
    const q = useRequestQuery(event);
    console.log(q);
    // { key: ..., ... }

    return q;
}));

serve(router, { port: 3000 });
```

## Helpers

### `setRequestQuery`

This function sets the parsed request query parameters for the current request.

```typescript
declare function setRequestQuery(
    event: IAppEvent,
    key: string,
    value: unknown
) : void;

declare function setRequestQuery(
    event: IAppEvent, 
    record: Record<string, any>
) : void;
```

### `useRequestQuery`

This function returns the query parameters of the request.

```typescript
declare function useRequestQuery(
    event: IAppEvent
) : Record<string, any>;

declare function useRequestQuery(
    event: IAppEvent, 
    key: string
) : any;
```

## License

Made with 💚

Published under [MIT License](./LICENSE).

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