Vue
Accura IDScan Plugin — Vue 3 Integration Guide
Step 1: Initialize Project
npm create vite@latest my-id-app -- --template vue
cd my-id-app
npm installStep 2: Install Plugin
npm install accuraidscanpluginStep 3: Implementation
<script setup>
import { onMounted, onUnmounted } from 'vue';
let plugin = null; // Holds the active plugin instance for lifecycle management
onMounted(async () => {
// Dynamically import the plugin inside onMounted to guarantee browser-only execution.
// Vue's onMounted lifecycle hook runs exclusively on the client side,
// making it safe to access browser APIs such as the camera.
const { default: IDCardPlugin } = await import('accuraidscanplugin');
// Instantiate the plugin with:
// 1. The capture callback invoked when the scan is complete
// 2. A configuration object specifying card target and UI appearance
plugin = new IDCardPlugin(
handleCapture, // Fired automatically upon successful ID card scan
{
countryCode: "UGA", // Country code of the ID card
cardCode: "UGNIDF", // Card code ID front Card
topTextSize: "", // Top overlay text size (default if empty)
topTextColor: "", // Top overlay text color (default if empty)
topTextWeight: "", // Top overlay font weight (default if empty)
bottomTextSize: "", // Bottom overlay text size (default if empty)
bottomTextColor: "", // Bottom overlay text color (default if empty)
bottomTextWeight: "", // Bottom overlay font weight (default if empty)
}
);
// Activate the camera and begin the ID card detection session.
await plugin.start();
});
// Release camera resources and destroy the plugin when the component unmounts.
onUnmounted(() => {
if (plugin) {
plugin.destroy();
}
});
</script>Step 4: Response Handling
Property
Type
Description
Step 5: Demo Implementation
Step 6: Usage
Step 7: Running the Project
Last updated