Nextjs
Accura IDScan Plugin — Next.js Integration Guide
This guide walks you through integrating the Accura IDScan Plugin into a Next.js project using the App Router.
Step 1: Initialize Project
If you do not have an existing Next.js project, create one using the official CLI:
npx create-next-app@latest my-id-app
cd my-id-appStep 2: Install Plugin
Install the Accura IDScan Plugin package from the npm registry:
npm install accuraidscanpluginStep 3: TypeScript Support
Since the accuraidscanplugin package does not ship with TypeScript declarations, create a type definition file at the project root to resolve module errors:
// types.d.ts (place in the project root)
declare module 'accuraidscanplugin';Ensure this file is referenced in your tsconfig.json's include array:
Step 4: Implementation
Create components/IDScanner.tsx. The snippet below demonstrates only the plugin import and instantiation — the minimal code required to activate the ID scan engine in a Next.js client component:
Step 5: Response Handling
When the plugin completes an ID card scan, it invokes the handleCapture callback with a payload object. This object may contain one or both of the following properties:
front
string
Base64 Data URL of the front side of the ID card
back
string
Base64 Data URL of the back side of the ID card (if applicable)
What is Base64? Base64 is a binary-to-text encoding scheme that converts raw binary image data into a sequence of printable ASCII characters. Each scanned card image is delivered as a Data URL string (e.g., data:image/jpeg;base64,/9j/...), combining a MIME type prefix with the encoded image payload. Before transmitting to a server, this string must be decoded back into binary form (a Blob) to construct a valid multipart HTTP request.
The following demonstrates the base64-to-Blob conversion and API submission:
Step 6: Demo Implementation
The following is the complete, production-ready component. Copy and paste it directly into components/IDScanner.tsx. The original logic is preserved exactly as-is.
Step 7: Usage
Import and render the component in app/page.tsx:
Step 8: Running the Project
Last updated