Skip to content

Getting Started

Installation

sh
npm install vue-otp-pro
sh
pnpm add vue-otp-pro
sh
yarn add vue-otp-pro

Quick Start

Import the component and its styles:

vue
<script setup lang="ts">
import { ref } from 'vue'
import { OtpInput } from 'vue-otp-pro'
import 'vue-otp-pro/dist/vue-otp-pro.css'

const otp = ref('')

function handleComplete(value: string) {
  console.log('OTP entered:', value)
}
</script>

<template>
  <OtpInput v-model="otp" @complete="handleComplete" />
</template>

Try it:

Live Preview

Global Registration

Register the component globally with the Vue plugin:

ts
import { createApp } from 'vue'
import { VueOtpPro } from 'vue-otp-pro'
import 'vue-otp-pro/dist/vue-otp-pro.css'

const app = createApp(App)
app.use(VueOtpPro) // registers <OtpInput> globally
app.mount('#app')

With Nuxt

ts
// plugins/vue-otp-pro.client.ts
import { VueOtpPro } from 'vue-otp-pro'
import 'vue-otp-pro/dist/vue-otp-pro.css'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueOtpPro)
})

Peer Dependencies

Vue OTP Pro requires Vue 3.3+ as a peer dependency.

What's Next?

Pratik Patel

Pratik Patel

Enjoying Vue OTP Pro? Consider sponsoring to support continued development and new features.