React Native Redirect Example

React Native mobile apps will require a redirect to the web browser to create a users bank account. The following code example will provide an implementation where you can redirect to a web browser to add a bank account and then redirect the user back to your mobile app.

Use solana in the path segment even if you aren’t using a Solana wallet — this is a URL routing convention from our session-key endpoint, not a chain requirement.

Example
1export default function HomeScreen() {
2 const [isLinking, setIsLinking] = useState(false);
3
4 const handleRedirect = () => {
5 const deepLinkUrl = 'exp://10.0.0.19:8081';
6
7 const session_key = "USER_SESSION_KEY" // replace with a session key generated here: /api-reference/api-reference/authentication/get-session-key
8 const pathSegment = "solana"; // fixed URL routing convention — not a chain selector
9 const coinflowUrl = `https://sandbox.coinflow.cash/${pathSegment}/withdraw/YOUR_MERCHANT_ID?sessionKey=${session_key}&bankAccountLinkRedirect=${encodeURIComponent(deepLinkUrl)}`
10
11 console.log('coinflow url', coinflowUrl);
12
13 // open url in browswer
14 Linking.openURL(coinflowUrl).catch((error) => {
15 console.error('error opening url', error);
16 setIsLinking(false);
17 });
18 };
19
20 useEffect(() => {
21 handleRedirect();
22 }, []);
23
24 return null;
25}