Working with Server
By default the Kanban widget works entirely in the browser - you pass a cards array and every change stays in memory. When you need persistence, wire the board to a backend through the built-in RestDataProvider or handle actions manually. For large datasets, dynamic loading lets columns fetch their cards only when they become visible.
The full backend source code is published at Kanban Go backend repository.
RestDataProvider
RestDataProvider maps the five card-level store actions to conventional REST endpoints under a single URL root:
| Action | HTTP call |
|---|---|
add-card | POST /cards |
update-card | PUT /cards/:id (debounced 500 ms) |
move-card | PUT /cards/:id/move |
delete-card | DELETE /cards/:id |
duplicate-card | POST /cards/:id/duplicate |
The provider also converts dates. On load, it parses deadline strings from the server into Date objects. On save, it serializes Date values as ISO strings.
Two steps connect the provider to the board: call getData() for the initial fetch, then attach the provider inside init so subsequent user actions flow to the server.
Loading initial cards
Call getData() to fetch cards from the server and assign them to the cards prop. It issues GET /cards and parses dates before returning the result.
<script setup>
import { Kanban, RestDataProvider } from "@svar-ui/vue-kanban";
import { ref } from "vue";
const url = "https://api.example.com";
const provider = new RestDataProvider(url);
const cards = ref([]);
provider.getData().then(data => {
cards.value = data;
});
</script>
<template>
<Kanban :cards="cards" :columns="columns" />
</template>
cards is reactive, so assigning the fetched array triggers a render once data arrives. Until then the board shows empty columns.
Saving to backend
Wire the provider into the action pipeline with api.setNext(provider) inside the init callback. After that, every add-card, update-card, move-card, delete-card, and duplicate-card action from the UI forwards to its REST endpoint automatically.
<script setup>
import { Kanban, Editor, RestDataProvider } from "@svar-ui/vue-kanban";
import { ref } from "vue";
const url = "https://api.example.com";
const provider = new RestDataProvider(url);
const api = ref(null);
const cards = ref([]);
provider.getData().then(data => {
cards.value = data;
});
function init(kanbanApi) {
kanbanApi.setNext(provider);
}
</script>
<template>
<Kanban ref="api" :init="init" :cards="cards" :columns="columns" />
<Editor v-if="api" :api="api" />
</template>
The add-card request body carries the card fields plus before: the backend id of the card the new one goes in front of, or null to append. The provider ignores the local card id and uses the id the backend returns.
A move-card payload can include swimlane (PRO) when a card moves between lanes. The provider sends the payload as is, so your backend must save the swimlane field together with the column and before anchor.
The store validates add-card and move-card before it changes anything. If the action is rejected (for example, the target column or the before card doesn't exist), the handler returns false and the action never reaches the provider. The backend gets no request for it.
The provider runs after the store's default handler and any on listeners. You can combine it with intercept to validate or enrich payloads before they hit the network:
function init(api) {
api.setNext(provider);
api.intercept("add-card", ev => {
ev.card.priority = 1;
});
}
Saving columns and swimlanes
Column and swimlane edits go through the same provider. Both axes use the same endpoint pattern, where :axis is columns or swimlanes:
| Action | HTTP call |
|---|---|
| add | POST /:axis (full config and before) |
| update | PUT /:axis/:id (debounced 500 ms) |
| move | PUT /:axis/:id/move with { before } |
| delete | DELETE /:axis/:id |
A missing before anchor is sent as null, which means "append". When the backend answers an add request with a new id, the provider maps it to the local id. Requests that are still in the queue then use the backend id, both in URLs and in before anchors. The local id on the board doesn't change.
Customizing date serialization
If your backend expects dates in a format other than ISO 8601, subclass RestDataProvider and override formatDate:
class CustomProvider extends RestDataProvider {
formatDate(date) {
return date.toISOString().split("T")[0]; // "2025-06-15"
}
}
Live updates with KanbanEventBridge
When several users edit one board, each client must see the changes the others make. KanbanEventBridge from @svar-ui/kanban-provider listens to a server-sent events (SSE) stream and replays remote changes into the widget.
new KanbanEventBridge(url, clientId, api, provider, events);
url- the SSE endpoint; the bridge opens oneEventSourceon it.clientId- an id unique to this client. The bridge skips events whoseclientfield equals it, so a client doesn't apply its own changes twice.api- the Kanban instance API that receives the replayed actions.provider- theRestDataProviderthat saves this client's changes. The bridge uses its queue to map backend ids to local ids.events- maps each event name to an id kind or a custom handler.
An id kind is one of the CARDS, COLUMNS, or SWIMLANES constants. With CARDS, the bridge converts id, before, and card.id from backend ids to local ids and parses a string card.deadline into a Date. With COLUMNS and SWIMLANES, the payload is passed as is. A custom handler (data) => void | boolean can change the payload in place; return false to drop the event.
The bridge runs each event's op on api with skipProvider: true, so the replayed change isn't sent back to the backend.
<script setup>
import { ref, onUnmounted } from "vue";
import { Kanban } from "@svar-ui/vue-kanban";
import {
RestDataProvider,
KanbanEventBridge,
CARDS,
} from "@svar-ui/kanban-provider";
const url = "https://api.example.com";
const clientId = crypto.randomUUID();
const provider = new RestDataProvider(url);
provider.setHeaders({ "X-Client-Id": clientId });
const cards = ref([]);
let bridge;
provider.getData().then(data => {
cards.value = data;
});
function init(api) {
bridge = new KanbanEventBridge(`${url}/events`, clientId, api, provider, {
"add-card": CARDS,
"update-card": CARDS,
"move-card": CARDS,
"delete-card": CARDS,
});
api.setNext(provider);
}
onUnmounted(() => bridge?.close());
</script>
<template>
<Kanban :init="init" :cards="cards" :columns="columns" />
</template>
Send clientId with every request (here through the X-Client-Id header) so the server can tag the events it broadcasts. Call close() to stop the stream and its auto-reconnect. You can't reopen a closed bridge; create a new one instead.
Dynamic loading
The functionality is available in PRO Edition only
Loading every card up front isn't always practical. With dynamic loading, the board starts with an empty cards array. Each column requests its data only when it becomes visible and expanded.
Set dynamicData to enable the mode. When an expanded column with no data first appears on screen, the widget emits request-data with the column id. Your code listens for that action, fetches the cards, and responds with provide-data.
<script setup>
import { Kanban } from "@svar-ui/vue-kanban";
import { ref } from "vue";
const api = ref(null);
function onrequestdata(event) {
fetch(`/api/cards?column=${event.id}`)
.then(r => r.json())
.then(cards => {
api.value.exec("provide-data", {
id: event.id,
cards,
});
});
}
function init(kanbanApi) {
api.value = kanbanApi;
kanbanApi.on("request-data", onrequestdata);
}
</script>
<template>
<Kanban
:init="init"
:cards="[]"
:columns="columns"
dynamicData
/>
</template>
Each column transitions through three internal states: unknown (no data requested yet), loading (request in flight), and loaded (cards received). Once a column reaches loaded it stays there - the store doesn't re-fetch on subsequent scrolls. Filters and sorting apply to dynamically loaded cards the same way they apply to static ones.
The widget, not the store, decides when to request data, because only the rendered board knows which columns are visible. A request-data or provide-data call with an unknown column id does nothing. With swimlanes, requests stay per column: a column requests its cards once for all lanes.
Pair dynamic loading with column virtualization when the board has many columns, so only the visible subset triggers data requests:
<template>
<Kanban
:init="init"
:cards="[]"
:columns="columns"
dynamicData
:render="{
columnScroll: false,
virtualizeColumns: true,
columnOverscan: 0,
estimatedCardHeight: 96,
}"
/>
</template>
The stack layout (render.layout: "stack") places columns one under another, so there's no horizontal axis. There virtualizeColumns gates requests vertically: a column requests its data when one of its expanded groups is within one viewport height of the visible area.