---
title: "Invite people to a workspace"
description: "The invitation flow end to end: an owner or admin invites by email, the invitee signs in and accepts on /accept-invitation, and the inviter can cancel. The email, the link, the page and their limits."
canonical_url: "https://nuxt-backend.dev/docs/build/auth/workspaces/invitations"
---
# Invite people to a workspace

> The invitation flow end to end: an owner or admin invites by email, the invitee signs in and accepts on /accept-invitation, and the inviter can cancel. The email, the link, the page and their limits.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/components/workspaces/AcceptInvitation.vue)

A workspace grows by invitation. An owner or admin invites an address. The person gets an email with a link, signs in with that address, and accepts. The invitation also admits a new address while your app is [invite only](https://nuxt-backend.dev/docs/build/growth/launch), so an invited friend never meets a closed door.

Invitations are Better Auth's own, each bound to one address and one workspace. The package sends the email, mounts the page that accepts it, and limits how many go out.

## How it works

1. An owner or admin calls `useWorkspace().invite({ email, role })`, with `role` either `member` (the default) or `admin`. Inviting is a [sensitive action](https://nuxt-backend.dev/docs/build/auth/access/step-up#which-actions-ask), so it takes a sign-in from the last ten minutes.
2. The invitee gets the `invite` [email](https://nuxt-backend.dev/docs/build/email/templates), with a link to `{SITE_URL}{path}?id=<invitationId>`, where the path is `pages.acceptInvitation`, `/accept-invitation` by default.
3. The link opens the `/accept-invitation` page, which asks the invitee to sign in first, or to sign up with the invited address. The page renders `<AcceptInvitation>`: the workspace, who invited them, and **Accept** or **Decline**.
4. Accepting joins the workspace and makes it active. Declining rejects the invitation. Both land on the [activity trail](https://nuxt-backend.dev/docs/build/auth/admin/audit-log), without the address.

An invitation is for its address only: an account signed in with another address is refused. It expires after Better Auth's default 48 hours, which `workspaces.invitationExpiresIn` (in seconds) changes. The hourly maintenance deletes it 30 days after it expired. Members can't invite: only the owner and admins can.

## Invite from your own page

```vue [app/pages/team.vue]
<script setup lang="ts">
definePageMeta({ auth: true })

const { invitations, invite, cancelInvitation, error } = useWorkspace()
const { withReauthentication } = useReauthentication()
const email = ref('')

async function send() {
  await withReauthentication(() => invite({ email: email.value, role: 'member' }))
  email.value = ''
}
</script>

<template>
  <form @submit.prevent="send">
    <input v-model="email" type="email" autocomplete="off">
    <button type="submit">Invite</button>
  </form>
  <p v-if="error" role="alert">{{ error.message }}</p>
  <ul>
    <li v-for="invitation in invitations" :key="invitation.id">
      {{ invitation.email }} · {{ invitation.status }}
      <button type="button" @click="cancelInvitation(invitation.id)">Cancel {{ invitation.email }}</button>
    </li>
  </ul>
</template>
```

`invitations` is the active workspace's pending invitations, live. Inviting someone who is already a member, or already invited, is refused with the auth server's message in `error`.

<table>
<thead>
  <tr>
    <th>
      Action of <code>
        useWorkspace()
      </code>
    </th>
    
    <th>
      Who
    </th>
    
    <th>
      Does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        invite({ email, role? })
      </code>
    </td>
    
    <td>
      owner, admin
    </td>
    
    <td>
      Invites to the active workspace. Resolves with the invitation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cancelInvitation(id)
      </code>
    </td>
    
    <td>
      owner, admin
    </td>
    
    <td>
      Withdraws a pending invitation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        acceptInvitation(id, { activate? })
      </code>
    </td>
    
    <td>
      the invitee
    </td>
    
    <td>
      Joins, and with <code>
        activate: true
      </code>
      
       switches to the workspace. Resolves with the membership.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        declineInvitation(id)
      </code>
    </td>
    
    <td>
      the invitee
    </td>
    
    <td>
      Rejects the invitation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getInvitation(id)
      </code>
    </td>
    
    <td>
      the invitee
    </td>
    
    <td>
      The workspace and the inviter, for a page of your own, or <code>
        null
      </code>
      
       once it is no longer pending.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        listReceivedInvitations()
      </code>
    </td>
    
    <td>
      anyone signed in
    </td>
    
    <td>
      Every invitation addressed to the signed-in account.
    </td>
  </tr>
</tbody>
</table>

## Limits

Every invitation is an email from your domain, so two [rate limits](https://nuxt-backend.dev/docs/reference/backend/limits#rate-limits) bound them: `invitation` per inviter and `invitationGlobal` for the whole deployment. A refused invite answers `rate_limited` with the wait. A deployment that can't deliver the email refuses the invitation before it exists ([Deliverability](https://nuxt-backend.dev/docs/build/email/delivery/deliverability)).

## Change the email, the link or the page

- **The email.** Restyle the `invite` [template](https://nuxt-backend.dev/docs/build/email/templates) on `setupEmail`.
- **The link and the page.** Move the page with the module option `pages.acceptInvitation`, and the emails follow: the module writes the path to `backend/paths.generated.ts`, which `setupAuth` reads ([The paths file](https://nuxt-backend.dev/docs/reference/configuration/module-options#the-paths-file)). An app page at that path replaces the module's.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['nuxt-backend'],
  backend: { pages: { acceptInvitation: '/join' } },
})
```

```vue [app/pages/join.vue]
<script setup lang="ts">
definePageMeta({ auth: true })
</script>

<template>
  <AcceptInvitation @accepted="navigateTo('/studio')" />
</template>
```

`<AcceptInvitation>` reads `?id=` from the address. It shows one state at a time, each a slot of its own: `loading`, `ready`, `accepted`, `declined`, `missing` (gone, expired or already answered) and `error` (another account, or a refusal).

<warning>

Push the functions after you move the page: until the deployment carries the new paths file, invitation emails link to the old path and invitees get a 404. `npx nuxt-backend doctor` compares the deployment's path with `nuxt.config`: the [`page-paths`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#page-paths) finding.

</warning>

## Verify

1. As an owner, invite `delivered+friend@resend.dev`. The invitation shows in the [dev inbox](https://nuxt-backend.dev/docs/develop/dev-inbox).
2. Open its link signed out, sign in with the invited address, then accept. The workspace is now active.
3. Open the same link again. The page says the invitation is no longer there.

## Related

- [Create and switch workspaces](https://nuxt-backend.dev/docs/build/auth/workspaces): `useWorkspace` and the active workspace.
- [Manage members](https://nuxt-backend.dev/docs/build/auth/workspaces/members): what happens after someone joins.
- [Templates](https://nuxt-backend.dev/docs/build/email/templates): the `invite` email.
- [Workspace components](https://nuxt-backend.dev/docs/reference/components/workspaces#acceptinvitation): `<AcceptInvitation>` in full.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
