Skip to main content
A view is plain data, so it fits in a URL. tally-core writes a view to a query string and reads it back. useViewUrl in tally-react keeps the two in sync.

In React

accounts.tsx
On mount, a view in the URL replaces the grid’s view. Without one, the grid’s view is written to the URL. After that every view change updates the URL, and popstate restores the view of the history entry. The hook touches window only inside effects, so it is safe to render on the server.

The format

Filter, sort and group are written as query language text in q. The other parameters are written only when they differ from the schema’s default view. state is JSON encoded as base64url. It is the only part that is not readable. It is checked with validateView when read, so viewFromUrlString throws on a blob that does not match the view shape. useViewUrl catches it and keeps the current view. Other parameters in the query string are left alone. Commas, colons, parentheses and slashes stay unescaped so the link stays readable.

Without React

param changes the name of the query text parameter. base is a query string or URLSearchParams whose other parameters are kept.
links.ts
A view read from a URL goes through the same reconciliation as any other view. Unknown columns are dropped and new columns are added, so old links keep working after the schema changes. Parse errors in q are not raised. The view gets the query parseQuery built from the text. See Views for the view object and the view store.