@connextlive/nuxt3
v0.1.3
Published
ConnextLive Nuxt 3 module
Downloads
16
Readme
@connextlive/nuxt3
Minimal Nuxt 3 helper for ConnextLive (plugin content factory).
Install
npm install @connextlive/nuxt3 @connextlive/core
Setup
// plugins/connextlive.client.ts (client-only)
export default defineNuxtPlugin(() => {
if (process.client) {
const runtime = useRuntimeConfig()
const cfg = runtime.public?.connextlive || {}
if (!cfg.baseUrl) {
console.warn('[ConnextLive] Missing baseUrl in runtimeConfig.public.connextlive.baseUrl; widget will not load.')
return
}
if (!cfg.apiKey && !cfg.siteId) {
console.warn('[ConnextLive] Provide either apiKey or siteId in runtimeConfig.public.connextlive to load the widget.')
return
}
const query = cfg.apiKey ? 'apiKey=' + encodeURIComponent(cfg.apiKey) : 'siteId=' + encodeURIComponent(cfg.siteId || '')
const src = cfg.baseUrl + '/api/widget/embed?' + query + '&autoInit=' + String(cfg.autoInit ?? true)
useHead({ script: [{ src, defer: true }] })
}
})
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
public: {
// IMPORTANT: baseUrl must point to your ConnextLive backend domain,
// not the consumer site. Example: https://app.your-connextlive-domain.com
connextlive: { baseUrl: 'https://YOUR_CONNEXTLIVE_BACKEND', siteId: 'SITE_ID', autoInit: true }
}
}
})Notes
- Ensure the plugin filename ends with .client.ts so it only runs on the client.
- For cross-site installs, add the consumer domain to your Sites allowlist so CORS passes.
