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

# Profile Widget

Display a user's profile card with identity and social information.

<div align="center"><img src="https://i.ibb.co/bMmjMXp2/dotpassport-profile-widget.png" alt="Profile Widget" width="400"></div>

## Quick Start

```typescript
import { createWidget } from '@dotpassport/sdk';

const widget = createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile'
});

widget.mount('#container');
```

***

## Configuration Options

| Option           | Type                          | Default    | Description                 |
| ---------------- | ----------------------------- | ---------- | --------------------------- |
| `apiKey`         | `string`                      | *required* | Your DotPassport API key    |
| `address`        | `string`                      | *required* | Polkadot address to display |
| `type`           | `'profile'`                   | *required* | Widget type                 |
| `theme`          | `'light' \| 'dark' \| 'auto'` | `'light'`  | Color theme                 |
| `showIdentities` | `boolean`                     | `true`     | Display chain identities    |
| `showSocials`    | `boolean`                     | `true`     | Display social links        |
| `showBio`        | `boolean`                     | `true`     | Display user bio            |
| `className`      | `string`                      | `''`       | Custom CSS class            |
| `baseUrl`        | `string`                      | -          | Custom API base URL         |
| `onLoad`         | `() => void`                  | -          | Callback when loaded        |
| `onError`        | `(error: Error) => void`      | -          | Error callback              |

***

## Examples

### Full Profile

```typescript
createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  showBio: true,
  showSocials: true,
  showIdentities: true
}).mount('#container');
```

### Minimal Profile

```typescript
createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  showBio: false,
  showSocials: false,
  showIdentities: false
}).mount('#container');
```

### With Social Links

```typescript
createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  showSocials: true,
  showIdentities: false
}).mount('#container');
```

### Dark Theme

```typescript
createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  theme: 'dark'
}).mount('#container');
```

***

## React Integration

```tsx
import { useEffect, useRef } from 'react';
import { createWidget } from '@dotpassport/sdk';

interface ProfileWidgetProps {
  address: string;
  theme?: 'light' | 'dark' | 'auto';
  compact?: boolean;
}

function ProfileWidget({ address, theme = 'light', compact = false }: ProfileWidgetProps) {
  const containerRef = useRef<HTMLDivElement>(null);
  const widgetRef = useRef<ReturnType<typeof createWidget>>();

  useEffect(() => {
    if (!containerRef.current) return;

    widgetRef.current = createWidget({
      apiKey: process.env.REACT_APP_DOTPASSPORT_API_KEY!,
      address,
      type: 'profile',
      theme,
      compact,
      showAvatar: true,
      showBio: !compact,
      showSocials: !compact
    });

    widgetRef.current.mount(containerRef.current);

    return () => widgetRef.current?.destroy();
  }, [address, theme, compact]);

  return <div ref={containerRef} />;
}
```

***

## Vue Integration

```vue
<template>
  <div ref="container"></div>
</template>

<script setup>
import { ref, onMounted, onUnmounted, watch } from 'vue';
import { createWidget } from '@dotpassport/sdk';

const props = defineProps({
  address: { type: String, required: true },
  theme: { type: String, default: 'light' },
  showSocials: { type: Boolean, default: true }
});

const container = ref(null);
let widget = null;

onMounted(() => {
  widget = createWidget({
    apiKey: import.meta.env.VITE_DOTPASSPORT_API_KEY,
    address: props.address,
    type: 'profile',
    theme: props.theme,
    showSocials: props.showSocials
  });
  widget.mount(container.value);
});

onUnmounted(() => widget?.destroy());

watch(() => props.address, (newAddress) => {
  widget?.update({ address: newAddress });
});
</script>
```

***

## Profile Data

The profile widget displays:

### User Information

* **Display Name**: On-chain identity name
* **Avatar**: Profile picture (if set)
* **Bio**: User description

### Social Links

* Twitter/X
* GitHub
* Discord
* Telegram
* Email
* Website

### Chain Identities

* Polkadot identity
* Kusama identity
* Other parachain identities

***

## Event Handling

```typescript
const widget = createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  onLoad: () => {
    console.log('Profile loaded');
  },
  onError: (error) => {
    console.error('Failed to load profile:', error);
    // Show fallback UI for users without profiles
  }
});
```

***

## Handling Missing Profiles

```typescript
const widget = createWidget({
  apiKey: 'your_api_key',
  address: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
  type: 'profile',
  onError: (error) => {
    // User may not have a DotPassport profile yet
    document.getElementById('container').innerHTML = `
      <div class="no-profile">
        <p>This address doesn't have a DotPassport profile yet.</p>
        <a href="https://dotpassport.com/create">Create Profile</a>
      </div>
    `;
  }
});
```

***

## Related

* [Reputation Widget](/widgets/reputation.md)
* [Badge Widget](/widgets/badge.md)
* [Lifecycle Methods](/widgets/lifecycle.md)
* [Profile API Methods](/api-client/profile.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dotpassport.io/widgets/profile.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
