@enfyra/sdk-nuxt

Nuxt module for Enfyra — SSR-safe client, composables, and cookie bridge proxy
1,255
Install
npm install @enfyra/sdk-nuxt
Latest Version:1.0.6
Vue:3
License:MIT
Last Updated:Oct 23, 2026
Links: npm
Maintainer: dothinh

@enfyra/sdk-nuxt

Nuxt 3/4 module for Enfyra. Cookie-bridge auth, SSR-safe request-scoped client, and auto-imported composables. Requires Node.js 22.19 or newer.

Install

yarn add @enfyra/sdk-nuxt @enfyra/sdk-core

Set ENFYRA_APP_URL in your environment — that's it:

ENFYRA_APP_URL=https://admin.example.com
export default defineNuxtConfig({
  modules: ['@enfyra/sdk-nuxt'],
})

If you prefer config over env (e.g. for multi-tenant or per-environment overrides), set enfyra.appUrl instead — it takes precedence over the env var:

export default defineNuxtConfig({
  modules: ['@enfyra/sdk-nuxt'],
  enfyra: {
    appUrl: 'https://admin.example.com',
  },
})

No plugin, server middleware, route rule, or cookie handler needs to be written manually.

Options

All options are optional. appUrl falls back to ENFYRA_APP_URL when omitted.

Option Type Default Notes
appUrl string process.env.ENFYRA_APP_URL Server-only. Overrides the env var when set.
routePrefix string '/enfyra' Exposed to browser as the cookie-bridge proxy prefix.
proxy.headersTimeout number 300000 Maximum milliseconds to wait for upstream response headers. Set to 0 to disable.
proxy.bodyTimeout number 300000 Maximum milliseconds of inactivity between upstream response body chunks. Set to 0 to disable.

The proxy defaults can be overridden per application without changing the process-wide fetch dispatcher:

export default defineNuxtConfig({
  modules: ['@enfyra/sdk-nuxt'],
  enfyra: {
    proxy: {
      headersTimeout: 650_000,
      bodyTimeout: 650_000,
    },
  },
})

Composables

All composables are auto-imported — no manual imports needed.

useEnfyra

Returns the EnfyraClient instance for direct API access.

const client = useEnfyra()
const { data } = await client.get('/projects')

useAuth

const { user, isAuthenticated, pending, login, logout, refresh, oauthLogin } = useAuth()

await login({ email: 'user@example.com', password: '...' })
oauthLogin('google')

useQuery / useMutation

const { data, error, pending, meta, refresh } = useQuery('articles', {
  select: 'id,title,status',
  filter: { status: { _eq: 'published' } },
  limit: 20,
})

const { execute, pending: saving } = useMutation('articles')
await execute({ data: { title: 'Hello' } })

useStorage

const { upload, uploading, download, getDownloadUrl, getFolderTree } = useStorage()
const file = await upload(fileInput.files[0], { folder: 1 })

useWebSocket

const ws = useWebSocket('cloud', { immediate: true })
ws.on('cloud:project-changed', (event) => { ... })

SSR behavior

  • One EnfyraClient per incoming request; never cached across requests.
  • Forwards the request's Cookie and Authorization headers to the Enfyra App.
  • Appends rotated Set-Cookie headers back to the SSR response.
  • Browser traffic uses the same-origin /enfyra proxy with HttpOnly cookies.

What the module does

  • Proxies /${routePrefix}/** → ${appUrl}/api/** with manual redirects.
  • Creates a request-scoped client (SSR) or singleton (CSR) via a Nuxt plugin.
  • Auto-imports all composables.
  • Sets cookieBridgePrefix for OAuth redirect flows.

Related Packages

@enfyra/nuxt-seo

A powerful, configurable SEO module for Nuxt 4 with automatic OG image generatio...

2,867 0

Version History

Version Released Vue License
1.0.6 ^3.0 MIT
1.0.5 ^3.0 MIT
1.0.4 ^3.0 MIT
1.0.3 ^3.0 MIT
1.0.2 ^3.0