@@ -264,6 +264,33 @@ Complex modals use `@ebay/nice-modal-react` library. Simple dialogs use Gravity
264264
265265Uses React Router v5 hooks (` useHistory ` , ` useParams ` , etc.). Always validate route params exist before using them.
266266
267+ ### URL Parameter Management
268+
269+ - ** PREFER** ` use-query-params ` over ` redux-location-state ` for new development
270+ - ** ALWAYS** use Zod schemas for URL parameter validation with fallbacks
271+ - Use custom ` QueryParamConfig ` objects for encoding/decoding complex parameters
272+ - Use ` z.enum([...]).catch(defaultValue) ` pattern for safe parsing with fallbacks
273+
274+ ``` typescript
275+ // ✅ PREFERRED pattern for URL parameters
276+ const sortColumnSchema = z
277+ .enum ([' column1' , ' column2' , ' column3' ])
278+ .catch (' column1' );
279+
280+ const SortOrderParam: QueryParamConfig <SortOrder []> = {
281+ encode : (value ) => value ? encodeURIComponent (JSON .stringify (value )) : undefined ,
282+ decode : (value ) => {
283+ try {
284+ return value ? JSON .parse (decodeURIComponent (value )) : [];
285+ } catch {
286+ return [];
287+ }
288+ },
289+ };
290+
291+ const [urlParam, setUrlParam] = useQueryParam (' sort' , SortOrderParam );
292+ ```
293+
267294### Critical Rules
268295
269296- ** NEVER** call APIs directly - use ` window.api.module.method() `
@@ -274,6 +301,8 @@ Uses React Router v5 hooks (`useHistory`, `useParams`, etc.). Always validate ro
274301- ** ALWAYS** handle loading states in UI
275302- ** ALWAYS** validate route params exist before use
276303- ** ALWAYS** follow i18n naming rules from ` i18n-naming-ruleset.md `
304+ - ** ALWAYS** use Zod schemas for URL parameter validation with fallbacks
305+ - ** PREFER** ` use-query-params ` over ` redux-location-state ` for new URL parameter handling
277306
278307### Debugging Tips
279308
0 commit comments