# Keep React App State in the URL After Refresh

> Your AI moves filters, page, sort, search and the open item into the URL, so refresh, bookmarks and shared links show the same React screen.

Keep React App State in the URL After Refresh is a free AI agent skill on Agensi by 許威廉 willians, in Frontend & Web Apps. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [許威廉 willians](https://www.agensi.io/creators/willians888)
- Category: [Frontend & Web Apps](https://www.agensi.io/skills/frontend-web-apps)
- Version: 1.0
- Last updated: 2026-11-28
- Security: scan passed (2026-11-28); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/keep-react-app-state-in-the-url-after-refresh
- Tags: web-design, coding

## About this skill

Refresh sends your React app back to the home page? Your AI moves category, filters, page, sort, search and the open item into the URL, so reloads, bookmarks and shared links show the same screen. It brings a typed, dependency-free hook and covers the parts that usually break: junk params, resetting the page when filters change, Back closing a modal, and conflicts with React Router or Next.js.

Also replies in Traditional Chinese.

**Make a React single-page app remember where the user was: refresh, bookmark or share a link and land on the same filtered, paginated screen with the same item open.**

### What it does
Your AI reads your component (or your description), decides which state belongs in the URL, and wires it up:

- **What goes in the URL and what stays out**: filters, page, sort, search, view mode and the *ID* of the open item go in. Loading flags, toasts and form drafts stay out, and a modal's open state is derived from its ID.
- **A typed schema** with a default, parser and serializer for each param. Junk input such as `?page=-3&sort=hack` falls back safely. Defaults stay out of the URL, so the default screen has a clean address.
- **A ready-to-copy hook (`useUrlState.ts`)**: no dependencies, TypeScript, with replace and push modes. It handles Back/Forward, keeps UTM and other params, keeps `history.state` intact, and keeps several components in sync.
- **The interactions that break in real apps**: reset to page 1 when a filter changes, clamp the page when data shrinks, debounce search writes, make Back close a modal, and stop a visitor who arrived on a deep link from being sent off your site when they close the modal.
- **Router adapters** for React Router, Next.js (App and Pages Router) and TanStack Router, so it works with your router instead of fighting it.
- **A 12-point test checklist** plus round-trip unit tests for the schema.

### Who it's for
React developers with list, catalog, dashboard or search screens who are tired of users losing their place on refresh, or who need shareable deep links.

### How it works
1. It checks your routing setup and asks which states should survive a refresh.
2. It writes a param table: name, type, default, allowed values, and replace or push.
3. It adds the hook (or a router adapter) and edits your component.
4. It removes old one-off URL handling.
5. It walks through the test checklist and runs your type check or build.

### What you provide / what you get
**You provide:** your component code or repo, and your router if any.
**You get:** the param table, the hook file, the edited component(s) and the test steps.

### Example requests
- "My product grid forgets the category and page on refresh. No router, Vite + TS."
- "Next.js App Router: put the dashboard's date range and tab into the URL so I can share links."

### Requirements
A React project (hooks). Works with JavaScript or TypeScript. No new packages; if you already use a URL-state library, it uses that instead.

### Limits
Client-side UI state only, not server data or form drafts. Not for secrets or personal data, since URLs end up in history and logs. Keep URLs under about 2,000 characters. For server-rendered pages, the server-side read is pointed out but not built.

## Requires

- A React project (hooks)

## Known limitations

Client-side UI state only, not server data or form drafts. Not for secrets or personal data. Keep URLs under about 2,000 characters. For server-rendered pages, the server-side read is pointed out but not built.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Keep React App State in the URL After Refresh skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What does Keep React App State in the URL After Refresh do?

Your AI moves filters, page, sort, search and the open item into the URL, so refresh, bookmarks and shared links show the same React screen.

### Which AI agents support Keep React App State in the URL After Refresh?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use Keep React App State in the URL After Refresh?

Connect your AI agent to Agensi through MCP, then ask it to use Keep React App State in the URL After Refresh on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
