---
title: "Gravatar · Nuxt Scripts"
description: "Render server-hashed, proxied Gravatar images from an email or hash."
canonical_url: "https://scripts.nuxt.com/scripts/gravatar"
meta:
  "og:description": "Render server-hashed, proxied Gravatar images from an email or hash."
  "og:image": "https://scripts.nuxt.com/_og/s/o_9bc5c16c7de62e27.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Gravatar · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_9bc5c16c7de62e27.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **Gravatar**

[Copy for LLMs](https://scripts.nuxt.com/scripts/gravatar.md)

[**Gravatar**](https://gravatar.com) provides globally recognized avatars linked to email addresses. Its [**avatar API**](https://docs.gravatar.com/sdk/images/) uses a SHA-256 hash of the normalized email address. Nuxt Scripts creates that hash on your server and proxies the image request.

**Gravatar**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/gravatar.ts)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load Gravatar globally. Alternatively you can use the **useScriptGravatar** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      gravatar: {
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

This config automatically enables **first-party mode ** (bundle + proxy). See below to customise.

## useScriptGravatar()

The `**useScriptGravatar**` composable lets you have fine-grain control over when and how Gravatar is loaded on your site.

```
const { proxy } = useScriptGravatar()

// renders Gravatar avatar via component
```

Please follow the [**Registry Scripts **](https://scripts.nuxt.com/docs/guides/registry-scripts) guide to learn more about advanced usage.

## First-Party Mode: Privacy Focused Proxy

No extra config needed. The script is bundled from your domain (faster loads, no extra DNS lookup) and runtime requests are reverse-proxied through your server with automatic anonymisation (user IPs stay hidden from Gravatar, works with ad blockers). [**Learn more. **](https://scripts.nuxt.com/docs/guides/first-party)

**Mode**

Bundle Proxy

**Privacy**

User IP addresses are anonymised. Other request data passes through.

```
export default defineNuxtConfig({
  scripts: {
    // ✅ First-party mode: bundled + proxied
    registry: {
      gravatar: {
        trigger: 'onNuxtReady',
      },
    },
  },
})
```

## Example

Using Gravatar in a component with the proxy to send events .

ConversionButton.vue

```
<script setup lang="ts">
const { proxy } = useScriptGravatar()

// noop in development, ssr
// just works in production, client
function handleAction() {
  // renders Gravatar avatar via component
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>
```

## [`**<ScriptGravatar>**`](https://scripts.nuxt.com/scripts/gravatar)

The [`**<ScriptGravatar>**`](https://scripts.nuxt.com/scripts/gravatar) component renders a Gravatar avatar for a given email address. The avatar image request is proxied through your server, so Gravatar does not receive the user's IP address from that request.

Passing `**email**` puts the raw address in the same-origin image URL before the server hashes it. That URL can appear in browser, CDN, and server access logs. Pass a precomputed `**hash**` when the address should not enter those logs.

The integration also loads Gravatar's `**gprofiles.js**` directly for hovercard support, even when `**hovercards**` is `**false**`. The browser therefore still connects to Gravatar.

### Demo

**info@gravatar.com**

80×80px · Proxied through your server

### Props

| **Prop** | **Type** | **Default** | **Description** |
| --- | --- | --- | --- |
| `**email**` | `**string**` | - | Email address, sent to your server proxy for hashing, not sent to Gravatar |
| `**hash**` | `**string**` | - | Precomputed SHA-256 hash of the email (alternative to `**email**`) |
| `**size**` | `**number**` | `**80**` | Avatar size in pixels |
| `**default**` | `**string**` | `**'mp'**` | Default avatar style when no Gravatar exists |
| `**rating**` | `**string**` | `**'g'**` | Content rating filter |
| `**hovercards**` | `**boolean**` | `**false**` | Enable hovercards on hover |

## [`**useScriptGravatar()**`](https://scripts.nuxt.com/scripts/gravatar)

The [`**useScriptGravatar()**`](https://scripts.nuxt.com/scripts/gravatar) composable builds proxied avatar URLs from an email address or hash.

```ts
export function useScriptGravatar<T extends GravatarApi>(_options?: GravatarInput) {}
```

See [**Registry Scripts**](https://scripts.nuxt.com/docs/guides/registry-scripts) for trigger and loading options.

`**cacheMaxAge**``number` = 3600

Cache duration for proxied avatar images in seconds.

`**default**``string` = 'mp'

Default image to show when no Gravatar exists.

`**size**``number` = 80

Avatar size in pixels (1-2048).

`**rating**``string` = 'g'

Content rating filter.

## Example

Build an avatar URL after the Gravatar script loads:

```vue
<script setup lang="ts">
const { onLoaded } = useScriptGravatar()

const avatarUrl = ref('')

onLoaded((api) => {
  avatarUrl.value = api.getAvatarUrlFromEmail('user@example.com', { size: 120 })
})
</script>

<template>
  <img v-if="avatarUrl" :src="avatarUrl" alt="User avatar">
</template>
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/gravatar.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/gravatar.md)

[**Google Tag Manager** Load a GTM web container and push page or consent events from Nuxt.](https://scripts.nuxt.com/scripts/google-tag-manager) [**Hotjar** Load Hotjar and queue events, user attributes, and virtual page views.](https://scripts.nuxt.com/scripts/hotjar)

**On this page **

- [\<ScriptGravatar>](#scriptgravatar)
- [useScriptGravatar()](#usescriptgravatar)
- [Example](#example)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/gravatar#webpage","@type":"WebPage","description":"Render server-hashed, proxied Gravatar images from an email or hash.","name":"Gravatar","url":"https://scripts.nuxt.com/scripts/gravatar","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/gravatar#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/gravatar"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/gravatar#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Gravatar","item":"https://scripts.nuxt.com/scripts/gravatar","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
