---
title: "nuxt-backend/presence"
description: "Every export of nuxt-backend/presence, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/presence"
---
# nuxt-backend/presence

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · 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.

**Experimental**

Who is here: Convex's presence component, behind the backend's sign-in.
A heartbeat counts the signed-in account, never an id the browser names;
the room token it hands back is what lists the room, so only someone the
room let in reads who else is there, by name.

Experimental: it follows the presence component's pre-1.0 shapes, so this
entry's shape may change in a minor release.

## Interfaces

### PresenceComponents

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

The component handles `setupPresence` reads: pass the whole generated `components` object.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="presence">
        
      </a>
      
       <code>
        presence
      </code>
    </td>
    
    <td>
      <code>
        ComponentApi
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      { <code>
        adapter
      </code>
      
      : { <code>
        findOne
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >; }; }
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter
      </code>
    </td>
    
    <td>
      { <code>
        findOne
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.adapter.findOne
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### PresenceRoomCheck

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

Who a room may let in, asked on every heartbeat.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="roomid">
        
      </a>
      
       <code>
        roomId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The room the browser names, as <code>
        useRoomPresence
      </code>
      
       was given it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="userid">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The signed-in account.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claims">
        
      </a>
      
       <code>
        claims
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Its identity claims: its role, its active workspace (<code>
        activeOrganizationId
      </code>
      
      ) and the rest.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SetupPresenceOptions

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

Options for [setupPresence](#setuppresence).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="canjoin">
        
      </a>
      
       <code>
        canJoin?
      </code>
    </td>
    
    <td>
      (<code>
        room
      </code>
      
      , <code>
        ctx
      </code>
      
      ) => <code>
        boolean
      </code>
      
       | <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Whether a signed-in account may join a room, with the mutation's <code>
        ctx
      </code>
      
       to read your tables by. Unset, every signed-in account may join any room; refuse one by returning <code>
        false
      </code>
      
      , and the heartbeat answers <code>
        forbidden
      </code>
      
      . Rooms are the app's own strings: a document's id, <code>
        workspace:<id>
      </code>
      
      . It runs on heartbeats only, so it lets people in but never takes anyone out: the mutation that takes access away (a member removed from a workspace) also calls <code>
        presence.removeRoomUser
      </code>
      
      . <strong>
        Example
      </strong>
      
       <code>
        canJoin: ({ roomId, claims }) => !roomId.startsWith('workspace:') || roomId ===
      </code>
      
      workspace:${claims.activeOrganizationId}``
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       How many people a room lists at most. Default 50.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RoomMember

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

One person in a room, as `useRoomPresence` and the base module's `<FacePile>` read it.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid-1">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="online">
        
      </a>
      
       <code>
        online
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="lastdisconnected">
        
      </a>
      
       <code>
        lastDisconnected
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Their name, when the account has one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="image">
        
      </a>
      
       <code>
        image?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Their picture, when the account has one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### PresenceSetup

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

What [setupPresence](#setuppresence) returns: the three functions `backend/presence.ts` exports, and the component's own client.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="list">
        
      </a>
      
       <code>
        list
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        roomToken
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<a href="#roommember">
        <code>
          RoomMember
        </code>
      </a>
      
      <span>
        
      </span>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The room's people, by the room token a heartbeat handed back: who is online first, as the component orders them. Signed out, as an administrator acting as someone, or once <code>
        removeRoomUser
      </code>
      
       took the caller out of the room, it lists nobody and refuses.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="heartbeat">
        
      </a>
      
       <code>
        heartbeat
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        roomId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        sessionId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        interval
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <{ <code>
        roomToken
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        sessionToken
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Keep the signed-in account in a room. The browser's <code>
        userId
      </code>
      
       is checked against the account, never trusted.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="disconnect">
        
      </a>
      
       <code>
        disconnect
      </code>
    </td>
    
    <td>
      <code>
        RegisteredMutation
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        sessionToken
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        null
      </code>
      
      >>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       Leave the room the session token names, as a tab closes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="presence-1">
        
      </a>
      
       <code>
        presence
      </code>
    </td>
    
    <td>
      <code>
        Presence
      </code>
    </td>
    
    <td>
      <strong>
        <code>
          Experimental
        </code>
      </strong>
      
       The component's client, for a room of your own (<code>
        listRoom
      </code>
      
      , <code>
        removeRoomUser
      </code>
      
      , <code>
        removeRoom
      </code>
      
      ), which checks no sign-in. A refused heartbeat leaves the person in the room, with a room token that still lists it: <code>
        removeRoomUser
      </code>
      
      , called from the mutation that takes their access away, takes them out, and <code>
        list
      </code>
      
       then refuses them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts" rel="nofollow">
        src/convex/integrations/presence.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### setupPresence()

```ts
function setupPresence(components, options?): PresenceSetup;
```

Defined in: [src/convex/integrations/presence.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/presence.ts)

**Experimental**

Who is here, for a page, a document or a workspace: Convex's presence
component (`@convex-dev/presence`, mounted as `presence` in
`convex.config.ts`) behind the backend's sign-in. Export what it returns
from `backend/presence.ts`, and `useRoomPresence(roomId)` keeps the
signed-in person in the room and lists who else is there.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#presencecomponents">
        <code>
          PresenceComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#setuppresenceoptions">
        <code>
          SetupPresenceOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`PresenceSetup`](#presencesetup)

#### Example

```ts [backend/presence.ts]
import { setupPresence } from 'nuxt-backend/presence'
import { components } from './_generated/api'

export const { list, heartbeat, disconnect } = setupPresence(components)
```


## Sitemap

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