Decuga for Vue and Nuxt
Use a widget for a complete, themable page in one line, ChangelogFeed to draw the changelog in your own markup (rendered on the server, so search engines index it), or the composables to build every screen yourself.
Needs Vue 3.3 or newer. The package is in beta; the SDKs overview lists what you need first (a project id and the right plan).
Install
npm install @decuga/vue @decuga/elements@decuga/elements holds the widgets' web components. You need it for the three widgets, not for ChangelogFeed or the composables. It loads in the browser once a widget is on the page.
Set the project once
import { createApp } from 'vue'
import { createDecugaWithComponents } from '@decuga/vue'
import App from './App.vue'
createApp(App)
.use(createDecugaWithComponents({ projectId: 'YOUR_PROJECT_ID' }))
.mount('#app')That registers ChangelogFeed, DecugaChangelog, DecugaRoadmap and DecugaHelpdesk globally. Prefer to import components where you use them? Install createDecuga({ projectId }) instead, which sets the project and registers nothing. Every component and composable also takes projectId directly.
Ready-made widgets
<template>
<DecugaChangelog :page-size="5" />
<DecugaRoadmap view="board" show-header @vote="item => track('vote', item.title)" />
<DecugaHelpdesk form-id="OPTIONAL_FORM_ID" @submit="ticket => console.log(ticket.ticketNumber)" />
</template>Colours, font and corner radius come from CSS custom properties:
decuga-roadmap {
--decuga-color-primary: #0f766e;
--decuga-radius: 6px;
--decuga-font: 'Inter', sans-serif;
}<decuga-roadmap>) also works, if you tell Vue it is a custom element with compilerOptions.isCustomElement: tag => tag.startsWith('decuga-'). The components above need no such setting.Helpdesk for customers signed in to your app
DecugaHelpdesk normally asks for the customer's email and an emailed code. If your app already signs them in, give the plugin a session from your server and the widget opens on their requests, with no sign-in step and no sign-out button.
import { createApp } from 'vue'
import { createDecugaWithComponents } from '@decuga/vue'
const getSession = () => fetch('/decuga-session', { method: 'POST', credentials: 'include' }).then(r => r.json())
createApp(App)
.use(createDecugaWithComponents({ projectId: 'YOUR_PROJECT_ID', session: getSession }))
.mount('#app')
// <DecugaHelpdesk /> anywhere in the app now shows the signed-in customerChangelog in your markup
ChangelogFeed draws release notes as plain HTML elements in your page, with no shadow DOM, so your CSS applies and it can be drawn on the server. Class names start with decuga-.
<script setup lang="ts">
import { ChangelogFeed } from '@decuga/vue'
import '@decuga/client/changelog.css' // optional starter styles
</script>
<template>
<ChangelogFeed project-id="YOUR_PROJECT_ID" :page-size="5" />
</template>Draw an entry your own way with the entry slot. It receives the entry ready to draw (dates as text, only the sections that have content):
<ChangelogFeed project-id="YOUR_PROJECT_ID">
<template #entry="{ entry }">
<article>
<h3>{{ entry.title }} <small v-if="entry.version">{{ entry.version }}</small></h3>
<time :datetime="entry.dateIso ?? undefined">{{ entry.dateText }}</time>
<section v-for="s in entry.sections" :key="s.key">
<h4>{{ s.label }}</h4>
<ul><li v-for="(i, n) in s.items" :key="n">{{ i.title }}</li></ul>
</section>
</article>
</template>
</ChangelogFeed>It loads five entries and the next five as the visitor scrolls, and always shows a Load more button too.
Nuxt and server rendering
To put your release notes in the HTML Nuxt sends, fetch the first page on the server and give it to ChangelogFeed. Nuxt carries the data to the browser, so the page hydrates without asking again.
import { createDecugaWithComponents } from '@decuga/vue'
export default defineNuxtPlugin(nuxtApp => {
const { decugaProjectId } = useRuntimeConfig().public
nuxtApp.vueApp.use(createDecugaWithComponents({ projectId: decugaProjectId }))
})<script setup lang="ts">
import { DecugaClient } from '@decuga/client'
import '@decuga/client/changelog.css'
const { decugaProjectId } = useRuntimeConfig().public
const { data: initialPage } = await useAsyncData('changelog', () =>
new DecugaClient({ projectId: decugaProjectId }).changelog.page({ size: 5 }),
)
useHead({ title: 'Release notes' })
</script>
<template>
<ChangelogFeed :initial-page="initialPage ?? undefined" locale="en-US" />
</template>- Set
localewhen you render on the server (it defaults toen-US), so the server and browser write the same date. Dates show the calendar day stored in Decuga, whatever the visitor's time zone. - The widgets draw an empty tag on the server and fill in when the page is live, so they are safe in SSR. Composables load data in the browser.
Composables for your own UI
Each returns refs for the data, the loading and error state, and functions for the actions. You write the template.
useChangelog
<script setup lang="ts">
import { useChangelog } from '@decuga/vue'
const { entries, hasMore, loading, error, loadMore } = useChangelog({ projectId: 'YOUR_PROJECT_ID', pageSize: 10 })
</script>
<template>
<h3 v-for="e in entries" :key="e.id">{{ e.title }}</h3>
<p v-if="error">Could not load more.</p>
<button v-if="hasMore" :disabled="loading" @click="loadMore">Load more</button>
</template>useRoadmap
Voting needs a visitor who has verified their email. toggleVote rejects with a session-expired error when they have not, which is your cue to show your own sign-in (requestCode(email), then verifyCode(email, code)).
<script setup lang="ts">
import { useRoadmap, isDecugaError } from '@decuga/vue'
const { grouped, toggleVote } = useRoadmap({ projectId: 'YOUR_PROJECT_ID' })
async function vote(item) {
try { await toggleVote(item) }
catch (e) { if (isDecugaError(e) && e.code === 'session-expired') openSignIn() } // your sign-in UI
}
</script>
<template>
<button v-for="item in grouped.PLANNED" :key="item.id" :aria-pressed="item.hasVoted" @click="vote(item)">
{{ item.title }} ({{ item.voteCount }})
</button>
</template>useHelpdesk
It returns the portal settings, the forms the visitor may use, the signed-in customer and helpdesk, the client part with submitTicket, sendCode, verifyCode, myTickets, ticket and comment. Use validateTicket and buildTicketRequest (exported from the same package) to check a filled-in form and turn it into the request the portal expects.
Props and events
| Component | Props | Events |
|---|---|---|
DecugaChangelog | projectId, pageSize, infiniteScroll, initialPage, theme, locale | load, error |
DecugaRoadmap | projectId, view, showHeader, suggestions, theme, locale | load, vote, signin, suggest, error |
DecugaHelpdesk | projectId, formId, showHeader, tickets, theme, locale | submit, signin, error |
ChangelogFeed | projectId, initialPage, pageSize, infiniteScroll, locale | None. Slots: entry, empty |
Every component also takes baseUrl (default https://decuga.com), storage ("session", "local" or "memory"; where a signed-in visitor is remembered) and client (a client you made yourself, handy in tests).