- Home
- Skills
- Frontend & Web Apps
- Keep React App State in the URL After Refresh
Works with the AI Agents you already use
Keep React App State in the URL After Refresh
by 許威廉 willians
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.
Free
Keep React App State in the URL After Refresh
Example session with this skill installed
Keep category, page and the open product modal in the URL. Vite + TypeScript, no router. Back should close the modal.
- Read your context and instructions
- Compiled the keep react app
A param table (cat: string, default '', replace; page: int ≥1, default 1, replace; item: id, default null, push), the useUrlState.ts hook copied to src/hooks/, the edited ProductGrid component (page resets to 1 on category change, modal opens from ?item= and Back closes it), and the 12-point test checklist with pass/fail results.
Connects securely to your tools. The creator never sees your data.
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=hackfalls 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, keepshistory.stateintact, 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
- It checks your routing setup and asks which states should survive a refresh.
- It writes a param table: name, type, default, allowed values, and replace or push.
- It adds the hook (or a router adapter) and edits your component.
- It removes old one-off URL handling.
- 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.
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
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 7 days ago
- Free with an Agensi account
- Software
- A React project (hooks)
Permissions
File Scopes
Reads and edits the user's React components, adds one hook file, and may run the project's type check or build. No network access, no API keys.
What's inside
Frequently Asked Questions
New in Frontend & Web Apps
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Frontend & Web Apps.