Nuxt

Module

Auto-imports for the composable, scanner component, and overlay.

Nuxt module

@orbisk/nuxt-barcode-detection registers the composable as an auto-import and the scanner + overlay as global components, so you can drop them anywhere in your Nuxt app without importing.

Setup

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@orbisk/nuxt-barcode-detection'],
})

What you get

  • useBarcodeDetector — auto-imported composable. See useBarcodeDetector for the full reference.
  • <UseBarcodeDetector /> — drop-in scanner component, registered globally.
  • <BarcodeDetectorOverlay /> — standalone SVG overlay drawing accepted (green) and rejected (red) barcode polygons. Registered globally.
  • <UBarcodeInput /> — opt-in input field paired with a scan button. Only registered when @nuxt/ui is present in your app. See the Nuxt UI integration page for the full reference.

Options

Configure the module under the barcodeDetection key.

OptionTypeDefaultDescription
polyfillbooleanfalseRegister a client plugin that loads the barcode-detector polyfill on demand.

Usage

pages/scan.vue
<template>
  <UseBarcodeDetector v-slot="{ start, stop, isActive, detected }">
    <button @click="isActive ? stop() : start()">
      {{ isActive ? 'Stop' : 'Start camera' }}
    </button>
    <ul>
      <li v-for="b in detected" :key="b.rawValue">
        <strong>{{ b.format }}</strong><code>{{ b.rawValue }}</code>
      </li>
    </ul>
  </UseBarcodeDetector>
</template>

No imports needed — the composable and components are auto-registered.

Polyfill on the client

To support browsers without a native BarcodeDetector (Firefox, Safari, desktop Linux Chromium), enable the polyfill option:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@orbisk/nuxt-barcode-detection'],
  barcodeDetection: {
    polyfill: true,
  },
})

The module ships a client-only plugin that conditionally loads the barcode-detector polyfill — only when globalThis.BarcodeDetector is missing — so native implementations keep winning where they exist.

The plugin also exposes a useState<boolean>('barcode-detector-polyfilled') flag so you can show a banner or warning when the polyfill is active.

Install wizard. The first time you add the module, an interactive prompt asks whether to enable polyfill support. On confirm, the wizard installs barcode-detector (using your project's package manager via nypm) and writes barcodeDetection: { polyfill: true } into your nuxt.config automatically — so you don't need to set it yourself. The wizard skips itself in CI and non-TTY environments.
Copyright © 2026