Skip to main content
Introducing packages.sweber.dev
Inverse overview

InverseLive demo.

Everything on this page runs the real @sweberdev/inverse and @sweberdev/inverse-react packages in your browser: the buttons and forms in the made-up shop, the handler that would run on your server, the page check and the deadline helpers.

Nothing you enter leaves your browser. The handler runs locally here, so the e-mail is shown instead of sent.

Shop

Withdraw and cancel, end to endUse the footer.

Muster Outdoor is a made-up shop that also sells a gear subscription. Its footer has the two links the law asks for. Follow one, fill in the form, confirm on the second step, and watch what your server and the customer's inbox get.

Both duties apply to online contracts with consumers.

Muster Outdoor

Bereit für den Herbst

Ihre Bestellung A-1001 wurde am Freitag geliefert.

  • Regenjacke Alpin
  • Wanderschuh Grat
  • Gear-Box Abo

Customer's inbox

The acknowledgement e-mail appears here after you confirm.

What your server stores

onDeclaration(record) is called with this record.

The demo works out the end date with contractEndDate(): one month's notice, term until 31 December.

Without React

WordPress, Shopify, plain HTMLOne script tag.

Most shops and company sites do not run React. The same two-step form comes as a framework-free module and as one script from jsDelivr or unpkg that mounts every marked element. This sample page uses it in Dutch, Spanish, Polish or German; the withdrawal labels follow the wording of the EU directive in each language.

Atelier Holzwerk
Impressum

All the markup the page needs

<!-- e.g. a WordPress "Custom HTML" block -->
<div data-inverse-form="withdrawal"
     data-endpoint="https://example.com/api/inverse"
     data-show-items></div>

<!-- footer -->
<a data-inverse-link="withdrawal" href="/widerruf"></a>

<script src="https://cdn.jsdelivr.net/npm/@sweberdev/inverse@0.3/dist/inverse.global.js" defer></script>

Customer's inbox

The acknowledgement e-mail appears here after you confirm.

Page check

Is the button there?Paste HTML.

The same rules as npx inverse check. Pick an example or paste the HTML of your own footer. Information links such as "Widerrufsbelehrung" don't count; similar wording is flagged.

Examples

Result

Withdrawal button: Found

Found a control labelled like "Vertrag widerrufen".

  • Found <a> Vertrag widerrufen → /widerrufStatutory or equivalent wording.

Cancellation button: Found

Found a control labelled like "Verträge hier kündigen".

  • Found <a> Verträge hier kündigen → /kuendigenStatutory or equivalent wording.

Deadlines

When does it end?Two helpers.

withdrawalStatus() counts the 14 days from the day after delivery or contract moves the end off weekends and tells you how many days are left. contractEndDate() works out the end of a cancelled subscription from notice period and term.

Last day to withdraw: 4 December 2026Still open: 15 days left, today included.

Contract ends on: 20 December 2026

Free 2.0

One handler, eight legal areasInverse, free.

Inverse 2.0 knows the legal area of every declaration. Germany, Austria, Switzerland, France, Italy, Spain, the Netherlands and Poland are built in, and each record shows which state of the rules it followed.

Pick the legal area per shop or per request

Set a default jurisdiction and allow a list of others, so a shop that sells in several countries gets the right language and the right legal status on every record.

Handler options

import { createInverseHandler } from "@sweberdev/inverse";

export const POST = createInverseHandler({
  company: { name: "Acme SA" },
  jurisdiction: "de",
  jurisdictions: ["at", "fr"], // areas a request may pick
  onDeclaration,
  sendReceipt,
});

// request body: { kind: "withdrawal", jurisdiction: "fr", data: { ... } }

Real run: a request for fr is accepted, one for pl (not allowed) falls back to de

200 true
200 true
{ jurisdiction: 'fr', locale: 'fr', legalCheckedOn: '2026-10-12' }
{ jurisdiction: 'de', locale: 'de', legalCheckedOn: '2026-10-12' }

See how well each country is covered

The CLI prints the legal status of one area, its sources and what changed. France, Italy, Spain, the Netherlands and Poland say plainly that they rest on the directive only.

Terminal

npx inverse legal --jurisdiction fr

Output (trimmed)

France (fr): directive only, national act not read
The French implementing act was not read. Check the Code de la consommation on legifrance.gouv.fr.

Legal status checked on 2026-10-12

Sources:
  - Directive (EU) 2023/2673, Article 11a Consumer Rights Directive (withdrawal function)
  - National implementing act not read

Changes:
  2026-10-12  2.0.0  Legal status is kept per legal area (`legalRevisions`, `getLegalRevision`). France, Italy, Spain, the Netherlands and Poland added on the basis of the directive only. No change in requirements.
  ...

Let CI notice a legal change

With --since the command exits 1 when the library has a newer legal status than your last review, so a cron or CI job can remind you.

Terminal

npx inverse legal --jurisdiction de --since 2026-10-01   # exit 1 if something is newer

Output (trimmed)

$ npx inverse legal --jurisdiction de --since 2026-10-01
Germany (de): national provision checked
Both duties apply to online contracts with consumers.

Changes since 2026-10-01 (checked 2026-10-12):
  2026-10-12  2.0.0  Legal status is kept per legal area (`legalRevisions`, `getLegalRevision`). ...
  ...
exit code 1

$ npx inverse legal --jurisdiction de --since 2030-01-01
Germany (de): national provision checked
Both duties apply to online contracts with consumers.

Nothing new since 2030-01-01.
exit code 0

Read the legal status from code

The single legalRevision export became getLegalRevision per area. Use the checked date in your own compliance docs or to fail a build.

Node

import { getLegalRevision } from "@sweberdev/inverse";

getLegalRevision("fr").checkedOn;

Output

2026-10-12

France, Italy, Spain, the Netherlands and Poland follow Article 11a of the directive only; the national laws were not read and the texts are not reviewed by a lawyer or native speaker. 2.0 also needs Node 22.

Read the docs

Pro 3.0.0

The Pro packages as one serviceInverse Pro.

Pro 3.0.0 adds inverse-server: one Docker image that takes withdrawal and cancellation declarations from any shop, keeps them in a tamper-evident ledger, mails the receipt, runs the case inbox, reminds your team before deadlines and watches your pages. A WooCommerce plugin uses it. Nothing from 2.x was removed.

Start it with environment variables

The server stores the ledger in a SQLite file in the /data volume. It needs your company name, a sender, a mail server and a sign-in for the inbox. A wrong setting stops the container at start and names the setting.

One container

docker run -d --name inverse -p 8080:8080 -v inverse-data:/data \
  -e INVERSE_COMPANY_NAME="Acme GmbH" \
  -e INVERSE_MAIL_FROM="Acme <service@acme.example>" \
  -e INVERSE_SMTP_URL="smtp://user:password@mail.acme.example:587" \
  -e INVERSE_TEAM_EMAIL=recht@acme.example \
  -e INVERSE_INBOX_USER=team -e INVERSE_INBOX_PASSWORD='at-least-12-characters' \
  -e INVERSE_API_KEY="a-key-for-your-monitoring" \
  ghcr.io/weber-development/inverse-server:3

From declaration to refund, recorded

Recorded from a real run of the image with a mail server that records messages. The shop posts the declaration, the team finds the case in the inbox API, marks it refunded with a reply to the customer, and the ledger chain is intact. Then somebody edits the database, and the verify endpoint says where.

Recorded output

$ curl -s localhost:8080/v1/declarations -H "Content-Type: application/json" -d '{"kind":"withdrawal","locale":"de","data":{"name":"Max Muster","email":"max.muster@example.com","contractRef":"ORDER-1001","items":["Testprodukt"]}}' | jq "{ok, id, kind, receivedAt}"
{
  "ok": true,
  "id": "W-ST9CT6GZ",
  "kind": "withdrawal",
  "receivedAt": "2026-11-01T19:21:12.177Z"
}

$ curl -s -u team:$INBOX_PASSWORD localhost:8080/api/cases | jq ".cases[] | {ref, status, name, refundDue, daysLeft}"
{
  "ref": "W-ST9CT6GZ",
  "status": "open",
  "name": "Max Muster",
  "refundDue": "2026-11-15",
  "daysLeft": 14
}

$ curl -s -u team:$INBOX_PASSWORD -H "x-inverse-inbox: 1" -d "{\"status\":\"refunded\",\"amount\":\"49.90\",\"currency\":\"EUR\",\"reply\":\"refunded\"}" localhost:8080/api/cases/W-ST9CT6GZ/status | jq "{status: .case.status, mail}"
{
  "status": "refunded",
  "mail": "sent"
}

$ curl -s -H "Authorization: Bearer $MONITORING_KEY" localhost:8080/v1/ledger/verify | jq -c "{ok, entries}"
{"ok":true,"entries":3}

$ docker exec inverse node -e "…UPDATE inverse_ledger SET payload = replace(payload, \"Max Muster\", \"Mallory\") WHERE seq = 0"   # someone edits the database

$ curl -s -H "Authorization: Bearer $MONITORING_KEY" localhost:8080/v1/ledger/verify | jq -c "{ok, brokenAt, reason}"
{"ok":false,"brokenAt":0,"reason":"payload changed"}

Reminders and a watcher

With a team address set, the server mails a reminder three days, one day and on the day a refund is due, once per case and not for cases that are closed. With pages listed, it checks them for the buttons every six hours and raises an alarm by webhook and mail when one disappears.

Add them with two variables

-e INVERSE_WATCH_SITES="https://shop.acme.example/,https://shop.acme.example/account" \
-e INVERSE_WEBHOOK_URL="https://hooks.slack.com/services/…"

A WooCommerce plugin

A page with the shortcode [inverse_withdrawal] finds the order by number and e-mail address, or by the link from My Account, lets the customer pick items and sends the declaration from the shop server to your Inverse server. The order gets a note. We ran it against WordPress 7.1 and WooCommerce 11.2 in a browser; the forms pass axe-core.

Settings in WooCommerce → Inverse Pro

Inverse server:     https://widerruf.acme.example
Withdrawal page:    Widerruf   ([inverse_withdrawal])

The demo cannot run the server or the shop for you: it needs your own Docker host, a mail server and WordPress. Not verified: real SMTP servers and mail providers, PostgreSQL for the server, the watcher against live pages, load, several server processes on one data folder, pulling the image with a customer account. Shopware and Magento have no plugin. Not legal advice.

Read the docs

Pro 2.1.0

A web inbox and a watchdogInverse Pro.

Pro 2.1.0 adds a web inbox for withdrawal and cancellation cases and continuous monitoring of your sites. Both are in beta.

Web inbox for your casesBeta

Lists withdrawals and cancellations with status and refund day, marks overdue ones, changes the status in the ledger chain and sends a reply from a German or English template.

Start the inbox

export INVERSE_INBOX_PASSWORD="at-least-12-characters"
npx inverse-ledger inbox ./data/inverse.db --company "Acme GmbH"

Inbox inside your own serverBeta

Use the same inbox from code. Replies go out through any transport of inverse-mail, and inboxHandler lets you mount it in your own server.

createInbox and serveInbox

import { createInbox, serveInbox } from "@weber-development/inverse-ledger/node";

const inbox = createInbox({ ledger, transport, company });
serveInbox({ inbox, user, password });

Watch your sites for regressionsBeta

Each run checks your sites and reports only changes: a button that vanished, a site that stays broken, a site that is back. Alerts go to a webhook.

Scheduled watch run

npx inverse-audit watch --sites sites.txt --state state.json --webhook <url>

Generate the GitHub Actions workflowBeta

Prints a workflow that runs the watch on a schedule and fails the run on an alert, so GitHub notifies you by mail.

Print the workflow

npx inverse-audit init-action https://shop.example.com --webhook

The demo cannot show these: the inbox needs your own ledger and server (HTTPS in front of it), and the watch needs your own sites and a scheduler. Mail delivery through real providers and the generated workflow on a real GitHub runner are not yet tested against live systems.

Read the docs

Next

Add it to your appFour steps.

Install the two packages, add the route, add the two pages and link them from your footer. The getting started guide walks through it for Next.js.