> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gmail

> Mount a Gmail mailbox as a Mirage filesystem from Node or the browser.

`GmailVFS` browses messages, threads, and labels via the Gmail API.

Both runtimes share the same OAuth config: a Google Cloud `clientId` / `clientSecret` plus a long-lived `refreshToken` for the user. Setup steps live at [Google Workspace Credentials](/home/setup/google).

## Node

```bash theme={null}
pnpm add @struktoai/mirage-node
```

```ts theme={null}
import { GmailVFS, MountMode, Workspace } from '@struktoai/mirage-node'

const gmail = new GmailVFS({
  clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
  refreshToken: process.env.GOOGLE_REFRESH_TOKEN!,
})

const ws = new Workspace({ '/mail': gmail }, { mode: MountMode.READ })
await ws.shell('ls /mail/INBOX/')
```

## Browser

```bash theme={null}
pnpm add @struktoai/mirage-browser
```

```ts theme={null}
import { GmailVFS, MountMode, Workspace } from '@struktoai/mirage-browser'

const gmail = new GmailVFS({
  clientId: GOOGLE_CLIENT_ID,
  clientSecret: GOOGLE_CLIENT_SECRET,
  refreshToken: localStorage.getItem('gmail.refresh_token')!,
})

const ws = new Workspace({ '/mail': gmail }, { mode: MountMode.READ })
```

For OAuth in a browser, prefer PKCE so secrets stay off the page; the [Google setup guide](/home/setup/google) shows the flow.

## Config

| Field | Default | Notes |
| - | - | - |
| `clientId` | required | Google OAuth client ID. |
| `clientSecret` | required | Google OAuth client secret. Redacted in snapshots. |
| `refreshToken` | required | User's refresh token. Redacted in snapshots. |
| `refreshFn` | built-in | Optional override for the access-token refresh callback. |

## Mount mode

`read`. Partial write (drafts, labels) is exposed via Python and may land in TS in a future release.

For the mounted layout (labels, dates, attachments) see the [Python Gmail docs](/python/vfs/gmail).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.