# useQueryParam A hook built on top of React Router v5 that facilitate access and manipulation of query parameters. ### Why? 💡 - Facilitates editing the query string in the URL for the current location - Functions similarly to the useState hook - Does not rely on version 6 of the useSearchParams function from react-router-dom, ensuring compatibility with older versions ### Basic Usage: ```jsx harmony import { useState, useRef } from 'react'; import { HashRouter as Router } from 'react-router-dom' import { Typography, Tag, Input } from 'antd'; import useQueryParam from 'beautiful-react-hooks/useQueryParam'; const ExampleComponent = () => { // second parameter is optional const [param, setValue] = useQueryParam('foo', { initialValue: 'bar', replaceState: false, }) return ( Current value of 'foo' param is {param}< /Typography.Paragraph> setValue(e.targt.value)} /> ); }; ``` ### Types ```typescript static export interface UseQueryParamOptions { initialValue?: TValue; replaceState?: boolean; } /** * Ease the process of modify the query string in the URL for the current location. */ declare const useQueryParam: (key: string, options?: UseQueryParamOptions) => [TValue, (nextValue?: TValue | undefined) => void]; export default useQueryParam; ```