Skip to content

useQRCode

Category
Export Size
401 B
Package
@vueuse/integrations
Last Changed
4 weeks ago

Wrapper for qrcode.

Demo

Text content for QRCode
QR Code
Available in the @vueuse/integrations add-on.

Install

bash
npm i qrcode@^1

Usage

ts
import { useQRCode } from '@vueuse/integrations/useQRCode'

// `qrcode` will be a ref of data URL
const qrcode = useQRCode('text-to-encode')

or passing a ref to it, the returned data URL ref will change along with the source ref's changes.

ts
import { useQRCode } from '@vueuse/integrations/useQRCode'
import { shallowRef } from 'vue'

const text = shallowRef('text-to-encode')
const qrcode = useQRCode(text)
html
<input v-model="text" type="text" />
<img :src="qrcode" alt="QR Code" />

Type Declarations

typescript
/**
 * Wrapper for qrcode.
 *
 * @see https://vueuse.org/useQRCode
 * @param text
 * @param options
 */
export declare function useQRCode(
  text: MaybeRefOrGetter<string>,
  options?: QRCode.QRCodeToDataURLOptions,
): ShallowRef<string, string>

Source

SourceDemoDocs

Contributors

Anthony Fu
IlyaL
Anthony Fu
Doctorwu
Curt Grimes
Okuto Oyama
Alex Kozack
Antério Vieira

Changelog

v12.8.0 on
7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v10.0.0-beta.4 on
4d757 - feat(types)!: rename MaybeComputedRef to MaybeRefOrGetter
10e98 - feat(toRef)!: rename resolveRef to toRef

Released under the MIT License.