A complete, interactive data structure that includes all necessary information to display and interact with a Blink.
A Blink contains the complete, interactive data structure. It includes all necessary information to display and interact with a Blink, including its current state, possible actions, and related data.
This section covers adding blinks directly to your React Native dApp through our React Native SDK for Blinks. The SDK is completely open-source and can be found on our GitHub.
A getWalletAdapter function has to be defined to generate an BlinkAdapter for interactions with user wallets, like wallet connect and signing transactions through the React Native dApp.After that, the <Blink /> component can be used in the React Native dApp to render the Blink. It takes the following props:
theme - has the styling for the blink to be rendered;
blink - object returned from useBlink function (which requires the adapter from getWalletAdapter and Blink Provider URL);
websiteUrl - the complete URL of the Blink;
websiteText - the domain name of the Blink URL;
import { useBlink, type BlinkAdapter } from "@dialectlabs/blinks";import { Blink } from "@dialectlabs/blinks-react-native";import { PublicKey } from "@solana/web3.js";import type React from "react";function getWalletAdapter(): BlinkAdapter { return { connect: async (_context) => { console.log("connect"); return PublicKey.default.toString(); }, signTransaction: async (_tx, _context) => { console.log("signTransaction"); return { signature: "signature", }; }, confirmTransaction: async (_signature, _context) => { console.log("confirmTransaction"); }, };}export const BlinkInTheWalletIntegrationExample: React.FC<{ url: string; // could be blink api or website url}> = ({ url }) => { const adapter = getWalletAdapter(); const { blink } = useBlink({ url }); if (!blink) { // return placeholder component } const blinkUrl = new URL(url); return ( <Blink theme={{ "--blink-button": "#1D9BF0", "--blink-border-radius-rounded-button": 9999, // and any other custom styles }} blink={blink} adapter={adapter} websiteUrl={blinkUrl.href} websiteText={blinkUrl.hostname} /> );};
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.