> For the complete documentation index, see [llms.txt](https://docs.joeywallet.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.joeywallet.xyz/integration/actions/generate.md).

# Generate

The provider comes with a `generate` action that creates a connection URI and deeplink for custom wallet buttons and actions.&#x20;

```typescript
// Some where within your codebase...

const { actions } = useProvider();

const response = await actions.generate()
```

#### Input (Optional)

This action does not require any inputs (similar to the \`connect\` action), but allows for a \`walletId\` parameter which will automatically generate a custom URI and deeplink for a targeted wallet.&#x20;

{% hint style="info" %}
The `walletId` passed into the generate action has to match one of the wallet provided in the provider conifuration `walletDetails`. If not, the action will fallback to default wc syntax for the generated uri and deeplink (ie: wc://)
{% endhint %}

```typescript
{
    walletId?: string;    
    chain?: string;
    walletId?: string;
    pairing?: { topic: string };
    openModal?: boolean;
}
```

#### Return Type

The method will resolve if a connection is re-established by the user.

```typescript
Promise<{
    uri: string;
    deeplink: string;
}>
```

#### Example usage:

```jsx
// File: ./src/app/component.tsx
'use client';

import * as React from 'react';
import { useProvider } from './page';

import core from '@joey-wallet/wc-client/core';

const wallets = core.constants.wallets;

export default function Component() {
  const { actions, session, accounts } = useProvider();

const handleGenerate = () => {
  const generate = await actions.generate({
    walletId: wallets.joey.projectId,
  });

  // Get raw uri from generate function and manufacture deeplink for mobile
  const uri = generate.data?.uri;
  const deeplink = generate.data?.deeplink;

  if (isMobile) {
    const openDeeplink = (link: string) => (window.location.href = link);
    if (deeplink) openDeeplink(deeplink);
  } else {
    openModal && triggerModal(true);
  }

  return new Promise((resolve, reject) => {
    // Listen for connect event to capture session and URI
    const onConnect = () => {
      resolve(true);
      // Clean up listener
      provider.off('connect', onConnect);
    };

    // Handle provider errors
    const onError = () => {
      triggerModal(false); // Close modal on error
      reject(new Error(`Failed to connect`));
      provider.off('error', onError);
    };

    // Register event listeners
    provider.on('connect', onConnect);
    provider.on('error', onError);
  });
};

  return (
    <div>
      <button type="button" onClick={handleGenerate}>
        Generate
      </button>
      {session && (
        <div>
           <span>Successfully connected!</span>
              {accounts && accounts.map((account,index) => (
		<div key={index}>{account}</div>
	      )
            )}
        </div>
      )}
    </div>
  );
}
```
