Skip to content

Form Component ​

The FormComponent provides native form capabilities including input validation, autofill, and secure storage.

Basic Info ​

Description ​

This component handles native form interactions with enhanced security and autofill support.

How to Use ​

1. Web Implementation ​

javascript
import { useForm } from '@bagisto-native/react';

const CheckoutForm = () => {
    const { 
        autofillAddress, 
        validateField, 
        saveAddress,
        scanCreditCard 
    } = useForm();

    const handleAutofill = async () => {
        const address = await autofillAddress({
            type: "shipping", // or "billing"
            onComplete: (address) => {
                console.log("Autofilled address:", address);
                // Fill form fields
            }
        });
    };

    const handleCardScan = async () => {
        const cardData = await scanCreditCard({
            onSuccess: (card) => {
                console.log("Scanned card:", card);
                // Auto-fill card fields
            },
            onError: (error) => {
                console.log("Scan failed:", error);
            }
        });
    };

    return (
        <form>
            <button type="button" onClick={handleAutofill}>
                Autofill Address
            </button>
            <button type="button" onClick={handleCardScan}>
                Scan Card
            </button>
        </form>
    );
};

2. Native Side ​

kotlin
navigator.registerBridgeComponent("form", FormComponent(this))

API Reference ​

PropertyTypeRequiredDescription
autofillAddress()FunctionNoTrigger address autofill
validateField()FunctionNoValidate specific field
saveAddress()FunctionNoSave address for future use
scanCreditCard()FunctionNoOCR scan credit card

Autofill Types ​

TypeDescription
shippingShipping address
billingBilling address
contactContact information

Required Permissions ​

Add to AndroidManifest.xml:

xml
<uses-permission android:name="android.permission.CAMERA" />

Next Steps ​

Released under the MIT License.