# @dintero/discounts-web-sdk

> Dintero Discounts SDK for web frontends

Latest version **0.3.20** (published 2026-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dintero/discounts-web-sdk
pnpm add @dintero/discounts-web-sdk
yarn add @dintero/discounts-web-sdk
bun add @dintero/discounts-web-sdk
```

## 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.20 |
| Published | 2026-11-28 |
| First published | 2021-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 116.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Sven Nicolai Viig |
| Maintainers | svnv, frodeaa, andersem |

## Links

- npm: https://www.npmjs.com/package/@dintero/discounts-web-sdk
- Repository: https://github.com/Dintero/Dintero.Discounts.Web.SDK
- Homepage: https://github.com/Dintero/Dintero.Discounts.Web.SDK#readme
- Issues: https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues
- npm.io page: https://npm.io/package/@dintero/discounts-web-sdk

## Recent versions

- 0.3.20 (latest) — 2026-11-28
- 0.3.19 — 2026-11-04
- 0.3.18 — 2026-10-01
- 0.3.17 — 2026-09-13
- 0.3.16 — 2026-07-03
- 0.3.15 — 2026-07-01
- 0.3.14 — 2026-06-16
- 0.3.13 — 2026-05-07
- 0.3.12 — 2026-05-07
- 0.3.11 — 2026-04-09
- 0.3.10 — 2026-04-08
- 0.3.9 — 2026-03-27
- 0.3.8 — 2026-03-12
- 0.3.7 — 2026-02-18
- 0.3.6 — 2026-01-29
- … 34 more at https://npm.io/package/@dintero/discounts-web-sdk/versions

## README

# Dintero Discounts JavaScript SDK for frontend applications

[![Build Status](https://github.com/dintero/Dintero.Discounts.Web.SDK/workflows/CI/badge.svg)](https://github.com/dintero/Dintero.Discounts.Web.SDK/actions?query=workflow%3ACI+branch%3Amaster) [![npm latest version](https://img.shields.io/npm/v/@dintero/discounts-web-sdk/latest.svg)](https://www.npmjs.com/package/@dintero/discounts-web-sdk)

Use this SDK in your frontend application to embed one or more discounts from the Dintero Discount Service in your webpage.

[Learn more about the Dintero Discount Service at docs.dintero.com](https://docs.dintero.com/docs/discount-service/)

## Installation

**NPM package**

```
npm install @dintero/discounts-web-sdk
```

## Usage

**With a bundler**

```js
import { embed } from "@dintero/discounts-web-sdk";

embed({
    container: document.getElementById("deals-container"),
    api: {
        account: "P00000000",
        key: "public_api_key",
        secret: "abcdef01-2345-6789-abcd-ef0123456789",
    },
});
```

**With a script tag**

The package includes a UMD build, `dist/dintero-discounts-web-sdk.umd.min.js`, that exposes the SDK as the
global `discounts`. Copy it from `node_modules/@dintero/discounts-web-sdk/dist/` into your static assets and
include it before calling `discounts.embed`, as in the examples below.

```html
<div id="deals-container"></div>
<script src="/assets/dintero-discounts-web-sdk.umd.min.js"></script>
```

### Inline HTML JavaScript example getting a list of discounts with API access

In this example the SDK will try to fetch data from the discount service.

Make sure to configure the plugin with an API client that only has grants giving access to the
`public:discounts` scope.

```html
<script type="text/javascript">
    discounts.embed({
        container: document.getElementById("deals-container"),
        api: {
            account: "P00000000",
            key: "public_api_key",
            secret: "abcdef01-2345-6789-abcd-ef0123456789",
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
    });
</script>
```

### Inline HTML JavaScript example getting a single discount with API access

In this example the SDK will try to fetch data from the discount service for a given `discountId`.

Make sure to configure the plugin with an API client that only has grants giving access to the `public:discounts`-scope.

```html
<script type="text/javascript">
    discounts.embed({
        container: document.getElementById("deals-container"),
        api: {
            account: "P00000000",
            key: "public_api_key",
            secret: "abcdef01-2345-6789-abcd-ef0123456789",
            discountId: "1234",
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
    });
</script>
```

### Inline HTML JavaScript example with discount objects

In this example the SDK is supplied with a list of discount objects directly.

```html
<script type="text/javascript">
    discounts.embed({
        container: document.getElementById("deals-container"),
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
        discounts: [
            {
                id: "1",
                name: "Testvare",
                description: "Beskrivelse av testvare",
                requirement: {
                    item: { items: [{ id: "testvare-1" }] },
                    customer: {},
                    store_ids: ["*"],
                    purchase_to: "2030-06-13T21:59:00Z",
                    purchase_from: "2030-06-06T22:00:00Z",
                },
                limitation: {},
                reward: { type: "discount_item_new_price", value: 5000 },
                created_by: "DinteroTest",
                created_at: "2021-06-04T10:21:18.029Z",
                updated_at: "2021-06-04T10:21:18.029Z",
                receipt_text: "Ukens tilbud",
                type: "item",
                links: [
                    {
                        rel: "medium_discount_image",
                        href: "https://uploads-ssl.webflow.com/5f023ba9549ac22870f32943/5f1333ae5a496b0e0476975e_dintero-logo.svg",
                    },
                ],
                metadata: {
                    label: "Før: 100,-",
                    subtitle: "Ukens tilbud",
                    campaign_id: 1,
                },
                active: true,
            },
        ],
    });
</script>
```

### Inline HTML JavaScript example with discount webshop links and their link behaviour

In this example the SDK will try to fetch data from the discount service with webshop links.

The behaviour of opening links can be adjusted using `linkTarget` in the configuration.

`_self` (default) will open the webshop link directly on the same tab.

`_blank` will open the webshop link in a new tab.

```html
<script type="text/javascript">
    discounts.embed({
        container: document.getElementById("deals-container"),
        linkTarget: "_blank",
        api: {
            account: "P00000000",
            key: "public_api_key",
            secret: "abcdef01-2345-6789-abcd-ef0123456789",
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
    });
</script>
```

## Bugs

Bugs can be reported to https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues

## Security

Contact us at [security@dintero.com](mailto:security@dintero.com)

## Browser support

All major modern browsers above version `N - 1`, where `N` is the most recent version.

## Building from source

Requires the latest Node.js LTS (26) and [corepack](https://github.com/nodejs/corepack), which is no longer
bundled with Node.js: `npm install --global corepack`. The Makefile enables corepack and installs the
pinned pnpm version from `package.json`.

```bash
make build   # type check and build to dist/
make test    # run tests
make lint    # run biome checks
make watch   # rebuild on changes
```

Run `make help` to list all targets.

## Release

Releases are explicit: bump `version` in `package.json` on your branch and include it in the PR:

```bash
make bump-version              # patch, or BUMP=minor / BUMP=major
```

When merged to master, the release workflow (`make release`) publishes the package to npm
and creates the GitHub release/tag `v<version>` with generated release notes.
If the tag already exists, nothing is released.

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