Skip to main content

getCards

Returns the raw, unfiltered card array in the order it was provided. This is the persistence snapshot - filters and sorting don't affect it. Use it when you need to serialize the full card set to a backend or local storage.

Usage

getCards(): KanbanCard[]

The method returns the same array that the internal CardsStore holds. It reflects every mutation made through actions (add-card, update-card, move-card, delete-card, duplicate-card) but ignores active filters and sort criteria. The result is not reactive - it's a snapshot at the time of the call.

Example

import { useRef } from "react";
import { Kanban } from "@svar-ui/react-kanban";

function App() {
const apiRef = useRef(null);

function saveToServer() {
const cards = apiRef.current.getCards();
fetch("/api/cards", {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(cards),
});
}

return (
<>
<button onClick={saveToServer}>Save</button>
<Kanban ref={apiRef} cards={cards} columns={columns} />
</>
);
}
  • cards - the initial card array prop
  • getState - full state snapshot including viewData
  • export-data - export visible board (filtered view)