One another way to do that is as the following
import Router from 'next/router'
Router.push({
pathname: '/search',
query: {searchTerm: searchRef.current ? searchRef.current["value"] : '', codeSets: JSON.stringify(selectedCodeSets)}
}, '/search');
selectedCodeSets in this example is an array from state data
const [selectedCodeSets, setSelectedCodeSets] = useState<any>(['1']);
We can parse that data in the directed page like below
import {withRouter} from 'next/router'
const DaComponent = (props) => {
useEffect(() => {
let codeSets = JSON.parse(props.router.query.codeSets);
}, [props.router]);
};
export default withRouter(DaComponent);