Skip to content

Share Component ​

The ShareComponent provides native sharing capabilities for text, URLs, images, and files.

Basic Info ​

Description ​

This component enables native share sheets for sharing content to other apps and platforms.

How to Use ​

1. Web Implementation ​

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

const ShareButton = () => {
    const { share } = useShare();

    const handleShare = () => {
        share({
            title: "Check out this product",
            text: "I found this amazing product on the app!",
            url: "https://example.com/product/123",
            // Or share an image
            // image: "base64 encoded image or file:// path",
            onSuccess: () => {
                console.log("Share completed");
            },
            onError: (error) => {
                console.log("Share failed:", error);
            }
        });
    };

    return <button onClick={handleShare}>Share</button>;
};

2. Native Side ​

kotlin
navigator.registerBridgeComponent("share", ShareComponent(this))

API Reference ​

PropertyTypeRequiredDescription
titleStringNoShare sheet title
textStringNoText to share
urlStringNoURL to share
imageStringNoImage path or base64
fileStringNoFile path to share
onSuccessFunctionNoSuccess callback
onErrorFunctionNoError callback

Share Types ​

Text Share ​

javascript
share({ text: "Hello World" });

URL Share ​

javascript
share({ 
    title: "Product Page",
    url: "https://example.com/product/123"
});

Image Share ​

javascript
share({ 
    image: "file:///path/to/image.jpg"
});

File Share ​

javascript
share({ 
    title: "Download Report",
    file: "file:///path/to/report.pdf"
});

Next Steps ​

Released under the MIT License.