@enfyra/sdk-nuxt
@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
EnfyraClientper incoming request; never cached across requests. - Forwards the request's
CookieandAuthorizationheaders to the Enfyra App. - Appends rotated
Set-Cookieheaders back to the SSR response. - Browser traffic uses the same-origin
/enfyraproxy withHttpOnlycookies.
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
cookieBridgePrefixfor OAuth redirect flows.
Related Packages
A powerful, configurable SEO module for Nuxt 4 with automatic OG image generatio...
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 | ||
| 1.0.1 | ^3.0 | ||
| 1.0.0 | ^3.0 |