vue3-otp-input is a fully customizable, one-time password (OTP) input component designed for Vue 3 applications, leveraging the Vue Composition API. The current stable version is `0.5.40`, with a consistent release cadence addressing bug fixes and minor enhancements. Key differentiators include robust handling of mobile autofill, improved focus behavior, and specific fixes for iOS input issues, which were addressed in recent `0.5.x` releases. It is a lightweight component that ships with TypeScript types, providing a seamless integration experience for developers building modern Vue applications requiring secure and user-friendly OTP entry forms.
npm install vue3-otp-inputVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic usage of the OtpInput component in a Vue 3 Single File Component (SFC). It includes `v-model` for two-way data binding, sets the number of inputs and auto-focus, defines input types and styling, and handles `on-change` and `on-complete` events. It also shows how to clear the OTP programmatically.
Review your project's `vite.config.ts` if upgrading from a `vue-cli` based setup. Verify component imports and prop usages, especially if you were relying on undocumented internal structures. Re-test all OTP input functionalities thoroughly.
Upgrade to version `0.5.40` or later. This version includes fixes for 'paste otp codes from mobile autofill' and 'enhance OTP input handling for iOS and improve focus behavior', significantly improving usability on mobile platforms.
Upgrade to version `0.4.4` or newer. This version includes fixes for 'duplicate value when input from right and using 'v-model'' and 'Handle number input with type="text" but retain other n' for more reliable input handling.
Ensure you are using `import OtpInput from 'vue3-otp-input';` in your script section. If using options API, ensure it's registered in the `components` option: `components: { OtpInput }`.Initialize your `v-model` bound variable to an empty string, e.g., `const otpValue = ref('');` or `data() { return { otpValue: '' }; }`.Use a `ref` on the `OtpInput` component (e.g., `<OtpInput ref="otpInputRef" ... />`) and then call the `clearInput()` method: `otpInputRef.value?.clearInput();`.