Components

KHQR

A payment card for Cambodia's KHQR, with paid, expired and failed states.

Install with one command, or copy the files

Preview

Try each outcome, or wait a minute for the code to expire. The code in this demo is not a real payment.

KHQR

Sothearo Coffee

4.50 USD

Install

pnpx sothearo add khqr

It checks whether you use Vue, Nuxt or React, and adds only the files you need to your components folder, in khqr/. They're yours to change.

Usage

The card only shows a payment. Your server makes the KHQR payload, for example with the official bakong-khqr package, and tells the page when the payment lands. Pass the payload and the current status.

Checkout.vue
<script setup lang="ts">
import KhqrCard from "@/components/khqr/KhqrCard.vue";

const { payload, expiresAt } = await $fetch("/api/payments", { method: "POST" });
const status = ref("waiting");
</script>

<template>
  <KhqrCard
    :payload="payload"
    merchant="Sothearo Coffee"
    :amount="4.5"
    currency="USD"
    :status="status"
    :expires-at="expiresAt"
    @expire="status = 'expired'"
    @refresh="createPayment"
  />
</template>

Props

PropTypeDefaultWhat it does
payloadstringThe KHQR string from your server.
imagestringA code your server already drew, as a data URL or link. Use it in place of payload.
merchantstringName shown above the amount.
amountnumberLeave it out for a code that takes any amount.
currency"USD" | "KHR""USD"Sets the format and the sign in the middle of the code.
status"waiting" | "paid" | "expired" | "failed""waiting"What the card shows.
expires-atDate | numberShows a countdown and a bar that runs out.

Events

NameWhen
@expireThe countdown reaches zero while waiting.
@refreshThe person asks for a new code after it expires.
@retryThe person tries again after a failure.

Customise

khqr.css
[data-khqr] {
  --khqr-width: 320px;
  --khqr-radius: 24px;
  --khqr-success: #0f9d58;
}

The card carries data-status, so you can style each state.

Accessibility

  • The code has a label naming who you pay.
  • Paid and expired are announced as status, failed as an alert.
  • The code stays black on white in dark mode, so it always scans.
Code by day, manga by night.2026