# twing

> First-class Twig engine for the JavaScript ecosystem

Latest version **7.3.1** (published 2026-02-09) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install twing
pnpm add twing
yarn add twing
bun add twing
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.3.1 |
| Published | 2026-02-09 |
| First published | 2017-10-05 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 14 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Author | Eric MORAND |
| Maintainers | ericmorand |
| Keywords | browser, compiler, template, twig, twig-engine, typescript |

## Links

- npm: https://www.npmjs.com/package/twing
- Repository: https://gitlab.com/nightlycommit/twing
- Homepage: http://twing.nightlycommit.com
- Issues: https://gitlab.com/nightlycommit/twing/-/issues
- npm.io page: https://npm.io/package/twing

## Dependencies (14)

- [pad](https://npm.io/package/pad.md) ^2.0.3
- [luxon](https://npm.io/package/luxon.md) ^1.19.3
- [runes](https://npm.io/package/runes.md) ^0.4.3
- [esrever](https://npm.io/package/esrever.md) ^0.2.0
- [locutus](https://npm.io/package/locutus.md) ^2.0.31
- [isobject](https://npm.io/package/isobject.md) ^3.0.1
- [capitalize](https://npm.io/package/capitalize.md) ^1.0.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.6.3
- [snake-case](https://npm.io/package/snake-case.md) ^2.1.0
- [source-map](https://npm.io/package/source-map.md) ^0.6.1
- [twig-lexer](https://npm.io/package/twig-lexer.md) ^0.9.0
- [levenshtein](https://npm.io/package/levenshtein.md) ^1.0.5
- [regex-parser](https://npm.io/package/regex-parser.md) ^2.2.8
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^2.0.4

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 7.3.1 (latest) — 2026-02-09
- 4.0.0-beta.1 (next) — 2019-10-29
- 2.3.7 (2.x-latest) — 2019-10-23
- 7.3.0 — 2026-02-08
- 7.2.2 — 2025-10-20
- 7.2.1 — 2025-06-22
- 7.2.0 — 2025-06-20
- 7.2.0-beta.1 — 2025-06-19
- 7.1.3 — 2025-06-04
- 7.1.3-beta.1 — 2025-06-02
- 7.1.2 — 2025-06-01
- 7.1.1 — 2025-05-29
- 7.1.1-beta.1 — 2025-05-29
- 7.1.0 — 2025-05-29
- 7.1.0-beta.2 — 2024-07-27
- … 125 more at https://npm.io/package/twing/versions

## README

# Twing
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage percentage][coveralls-image]][coveralls-url] [![Donate][donate-image]][donate-url]

First-class JavaScript Twig compiler

## Prerequisites

Twing needs at least **node.js 16.0.0** to run.

## Installation

The recommended way to install Twing is via npm:

```shell
npm install twing --save
```

## Documentation

See [the Twing website](https://twing.nightlycommit.com) for documentation.

## Basic API Usage

```typescript
import {createEnvironment, createArrayLoader} from "twing";

const loader = createArrayLoader({
    'index.twig': 'Everybody loves {{ name }}!'
});

const environment = createEnvironment(loader);

environment.render('index.twig', {name: 'Twing'}).then((output) => {
    // output contains "Everybody loves Twing!"
});
```

## Script tag

Use [cdnjs](https://cdnjs.com/libraries/twing) to include Twing in your HTML document.

Once loaded by the browser, Twing is available under the global `Twing` variable.

## Related packages

* [gulp-twing](https://www.npmjs.com/package/gulp-twing): Compile Twig templates with gulp. Build upon Twing.
* [twing-loader](https://www.npmjs.com/package/twing-loader): Webpack loader that compiles Twig templates using Twing.

## License

Copyright © 2018 [Eric MORAND](https://github.com/ericmorand). Released under the [2-Clause BSD License](https://github.com/ericmorand/twing/blob/master/LICENSE).

[npm-image]: https://badge.fury.io/js/twing.svg
[npm-url]: https://npmjs.org/package/twing
[build-image]: https://gitlab.com/nightlycommit/twing/badges/main/pipeline.svg
[build-url]: https://gitlab.com/nightlycommit/twing/-/pipelines
[coveralls-image]: https://coveralls.io/repos/gitlab/nightlycommit/twing/badge.svg
[coveralls-url]: https://coveralls.io/gitlab/nightlycommit/twing
[donate-image]: https://img.shields.io/badge/Donate-PayPal-green.svg
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7YZU3L2JL2KJA

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