A link should reopen the view you meant to share
An operator filters an application queue to pending requests, sorts by oldest first, and sends the link to a teammate. The teammate opens the default queue and asks which records need attention.
The interface remembered the view only inside one browser session. The URL identified the dashboard, but left out the decisions that made it useful.
Search, filters, sorting, and pagination often deserve a place in the URL because users expect them to survive refreshes, bookmarks, and shared links.
Separate the saved view from the unfinished interaction
A committed filter describes which records the screen should show. A half-written search term describes what the user is currently typing. Those values can have different owners.
Keep an unfinished query local when the interaction needs an Apply button or a debounce. Once committed, let the URL describe the view and derive the results from it. This follows the same state ownership rule as any other React screen: avoid two independent copies that can disagree.
A useful view might look like this:
/dashboard/applications?status=pending&sort=oldest&page=2A private message draft or an open confirmation dialog usually does not belong there. Decide what reopening the link should reproduce before serializing every piece of component state.
Treat query parameters as untrusted input
Someone can edit the address bar, and old bookmarks can outlive today's filter options. Parse parameters into a small, explicit model before using them to query data.
type View = {
status: 'all' | 'pending' | 'reviewed';
sort: 'newest' | 'oldest';
page: number;
};
function parseView(params: URLSearchParams): View {
const status = params.get('status');
const rawPage = params.get('page') ?? '1';
const page = /^\d+$/.test(rawPage) ? Number(rawPage) : NaN;
return {
status: status === 'pending' || status === 'reviewed' ? status : 'all',
sort: params.get('sort') === 'oldest' ? 'oldest' : 'newest',
page: Number.isSafeInteger(page) && page >= 1 ? Math.min(page, 1000) : 1,
};
}The page cap is an example policy; choose limits and pagination methods that fit the data volume. Map allowed sort values to known query definitions rather than accepting arbitrary column names. Apply authorization separately on every read: a URL filter never grants access to a record.
Change related parameters together
If the user changes status while viewing page eight, reset pagination in the same navigation. The new result set may have only one page. With cursor pagination, discard the old cursor when changing the filter or sort.
Preserve unrelated parameters intentionally. A filter helper that rebuilds the query string from scratch can accidentally remove the current search term or selected sort.
In the Next.js App Router, a server page can read searchParams to load the matching data; client controls can use useSearchParams and router navigation to update the view. The official search and pagination tutorial demonstrates this flow, including resetting pagination when search changes.
Give browser history a useful meaning
Choose history behavior deliberately. Replacing the current entry can suit debounced typing, where Back should not replay each partial word. Pushing a new entry can suit explicit page changes or applied filters that users may want to revisit. Next.js documents the distinction between router.push and router.replace.
After Back or Forward navigation, controls and results should agree with the restored URL. If a local search draft remains on screen, define when it resets to the committed query.
Keep sensitive free text out of shareable parameters when possible. URLs can appear in browser history and operational logs; an internal dashboard URL still needs that judgment.
Check the link outside the current tab
Apply several filters, copy the URL into another authorized session, refresh, and use Back and Forward. Try invalid values and a filter that returns no records.
The link should reproduce the view definition, not promise an unchanged snapshot of live data. Records may change between visits. What should remain stable is the user's question: which records am I looking for, and in what order?