Svelte Server-Side Table

When the dataset is too large to send, the grid stops owning the rows and starts asking for them. You implement one getRows function that receives the current sort, filters and row range and returns the rows plus a total count; the grid handles caching, request cancellation, race safety and the loading state.

The same contract covers offset paging, keyset or cursor paging and infinite scroll, so moving from one to another is a change of options rather than a rewrite. Lazy grouping per level, tree data, pivot, transactions and select-all across rows the grid never loaded run on the same contract through the Enterprise server-side row model.

Turn it on: createServerDataSource(source, { pageSize: 50 })

Install

npm i @svgrid/grid

Free and MIT-licensed in @svgrid/grid: no license key, no row cap, no watermark.

The code

import { createServerDataSource, type ServerDataSource } from '@svgrid/grid'

const source: ServerDataSource<Row> = {
  async getRows({ startRow, endRow, sortModel, filterModel }) {
    const res = await fetch('/api/rows', {
      method: 'POST',
      body: JSON.stringify({ startRow, endRow, sortModel, filterModel }),
    })
    const { rows, total } = await res.json()
    return { rows, rowCount: total } // rowCount = total AFTER filtering
  },
}

const ctl = createServerDataSource(source, { pageSize: 50, onChange: (s) => (view = s) })
ctl.refresh()

What you get

Live examples

Documentation

Related articles

Frequently asked questions

How do I do server-side pagination in a Svelte table?

Create a ServerDataSource with a getRows function that receives startRow, endRow, sortModel and filterModel, and return the rows with the total count after filtering. Pass the controller's state to the grid.

What does the grid send to my endpoint?

The requested row range plus the current sort model and filter model. You decide how to turn those into SQL or an API call; the grid never assumes a backend.

Does it support infinite scroll?

Yes. Turn pagination off and the grid requests the next block as the user scrolls, keeping a window of rows rather than the entire result set.

Is server-side data free?

The contract, paged and infinite loading and cursor paging are MIT-licensed in @svgrid/grid. Lazy server-side grouping, tree data, pivot, transactions and select-all across rows the grid never loaded are the server-side row model in @svgrid/enterprise.

Build something else

Get started · Browse the gallery · Pricing