New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@opendatalabs/vana-react

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opendatalabs/vana-react

React hooks and components for Vana Network

latest
Source
npmnpm
Version
3.1.0
Version published
Maintainers
3
Created
Source

@opendatalabs/vana-react

React hooks and components for integrating with the Vana Network.

npm version Documentation License: MIT

Production-ready React components for Vana App builders

Drop in secure, type-safe data upload and social sharing instead of building custom iframe integrations, managing authentication, or writing boilerplate message protocols.

Solves:

  • Cross-origin iframe communication (we handle postMessage + origin validation)
  • Wallet authentication flows (pre-built, tested, Vana Network–compatible)
  • Data schema validation and upload (error handling included)
  • Social sharing with copy-to-clipboard (works everywhere)

Tightly integrated with Vana App infrastructure – components point to app.vana.com and handle all the plumbing.

npm install @opendatalabs/vana-react
# or
yarn add @opendatalabs/vana-react
# or
pnpm add @opendatalabs/vana-react

Components

VanaAppUploadWidget

An embeddable iframe widget that facilitates data upload operations for Vana Apps.

VanaAppUploadWidget Features

  • Cross-origin secure message communication
  • Wallet authentication support
  • Data upload with schema validation
  • Theme customization (CSS custom properties)
  • Full-viewport overlay (resize postMessage ignored/deprecated)
  • TypeScript support

VanaAppUploadWidget Usage

import { VanaAppUploadWidget } from "@opendatalabs/vana-react";

function App() {
  const handleResult = (result: any) => {
    console.log("Upload successful:", result);
  };

  const handleError = (error: string) => {
    console.error("Upload error:", error);
  };

  const handleAuth = (walletAddress: string) => {
    console.log("Authenticated:", walletAddress);
  };

  return (
    <VanaAppUploadWidget
      appId="your-app-id"
      onResult={handleResult}
      onError={handleError}
      onAuth={handleAuth}
      schemaId={123}
      prompt="Upload your data"
      operation="prompt_gemini_agent"
      operationParams={{ goal: "Analyze user data" }}
      theme={{ "--primary": "#007bff" }}
      isOpen={true}
      onClose={() => console.log("Widget closed")}
    />
  );
}

VanaAppUploadWidget Props

PropTypeRequiredDefaultDescription
appIdstringYes-Your Vana application ID
onResult(data: AgentOperationResult) => voidYes-Callback when data upload completes successfully
onError(error: string) => voidYes-Callback when an error occurs
onAuth(walletAddress: string) => voidYes-Callback when wallet authentication succeeds
isOpenbooleanNotrueControls visibility; iframe stays mounted for prefetching (fullscreen)
onClose() => voidNo-Fires when child posts uploader:closed
onReady() => voidNo-Fires after child ready and config sent; safe for animation timing
iframeOriginstringNohttps://app.vana.comOrigin URL for the iframe
schemaIdnumberNo-Schema ID for data validation
promptstringNo-LLM inference prompt (legacy; prefer operation + operationParams)
operationstringNo-Agent operation (e.g. prompt_gemini_agent, llm_inference)
operationParamsRecord<string, unknown>No-Params forwarded to personal server with the operation
filtersRecord<string, string>No-JSONPath filters per schema for data pre-filtering
themeVanaAppUploadThemeNo-CSS custom properties (e.g. { "--primary": "#6366f1" })
zIndexnumberNo1000Z-index for stacking control

Ref API

The VanaAppUploadWidget component supports React forwardRef to expose the underlying iframe element:

const iframeRef = useRef<HTMLIFrameElement>(null);

<VanaAppUploadWidget
  ref={iframeRef}
  appId="your-app-id"
  {...otherProps}
/>

// Access iframe programmatically
iframeRef.current?.contentWindow?.postMessage(...);

Security Considerations

Origin Validation: The widget validates the iframe's origin on the first ready message before posting configuration. This protects against:

  • Proxy/redirect chains that change the iframe's origin unexpectedly
  • CSRF-style attacks via compromised iframe sources
  • Message forwarding attacks (relay messages are filtered to "session"-only payloads)

Always use https://app.vana.com (or your authenticated domain) as the iframeOrigin prop. If you need to redirect or proxy the iframe, ensure the final destination origin matches your security policy.

Deprecated Props

  • className: No longer used; widget layout is fully controlled internally for fullscreen experience. Accepted for backward compatibility but has no effect.
  • resize postMessage: Ignored; widget is full-viewport by design. Height adjustment via postMessage is no longer supported.

VanaAppSocialShareWidget

A customizable social sharing component designed for Vana Data Apps. Provides seamless sharing to social platforms with copy-to-clipboard functionality and countdown notifications.

VanaAppSocialShareWidget Features

  • One-click sharing to Twitter, Facebook, LinkedIn, and Instagram
  • Copy-to-clipboard with automatic countdown timer
  • Theme customization with icon sizing
  • Flexible text generation with emojis and funny notes
  • Toast notifications with progress indicator
  • TypeScript support with full type definitions
  • Zero external UI dependencies

VanaAppSocialShareWidget Usage

import { VanaAppSocialShareWidget } from "@opendatalabs/vana-react";

function MyDataApp() {
  const handleShare = (platform: string) => {
    console.log(`User shared on ${platform}`);
  };
  return (
    <VanaAppSocialShareWidget
      appName="Ice Cream Flavor"
      shareContent="ChocoVision Leader (Dark Chocolate)"
      shareEmoji="🍦"
      funnyNote="Apparently I'm in the same league as Beyoncé!"
      title="Share your flavor"
      onShare={handleShare}
      classNames={{
        root: "text-center",
        button: "w-12 h-12 rounded-full bg-white shadow-md hover:scale-105",
      }}
      theme={{ iconSize: 20 }}
    />
  );
}

VanaAppSocialShareWidget Props

PropTypeRequiredDefaultDescription
appNamestringYes-Name of your Vana app (e.g., "Ice Cream Flavor")
shareContentstringYes-Main content to share (e.g., user's result)
shareEmojistringNo-Emoji to prepend to share content
funnyNotestringNo-Engaging note to add after content
titlestringNo"Share"Title displayed above share buttons
callToActionstringNo"Try @ app.vana.com"CTA text in share message
hashtagstringNo"#DATAREVOLUTION"Hashtag to append to message
themeVanaAppSocialShareThemeNo{}Theme configuration (iconSize)
onShare(platform: SocialPlatform) => voidNo-Callback when user shares
onShowToast(message: ToastMessage) => voidNo-Custom toast handler (uses internal if not set)
classNamesVanaAppSocialShareClassNamesNo{}Class names for all component parts
hideTitlebooleanNofalseHide the title section
renderButton(platform, Icon) => ReactNodeNo-Custom render function for buttons
buttonComponentReact.ComponentType<ShareButtonProps>No-Custom button component

ClassNames Options

PropertyTypeDescription
rootstringRoot container class
titlestringTitle section class (includes icon and text)
buttonsstringButtons container class
buttonstringBase class for all buttons
toaststringToast container class (if using internal toast)
toastContentstringToast content wrapper class
progressstringProgress bar class for countdown

Run development build with watch mode

npm run dev

Run tests

npm test

Build for production

npm run build

Run linting

npm run lint

Type checking

npm run typecheck

Testing

License

MIT © OpenDataLabs

Keywords

vana

FAQs

Package last updated on 20 Nov 2025

Related posts