🦔

Next.jsでクエリパラメーターを全て取得する

2024/03/07に公開

地味に詰まったのでメモ

import { useRouter, useSearchParams } from "next/navigation";

const searchParams = useSearchParams();
const params = searchParams?.toString();
const url = params ? `/?${params}` : "/";

const handleClick = () => {
    router.push(url);
};

Discussion