📍 Client Side URL Handling in Next.js

🔹 You can also get url with useParams on client side

using useParams Url = 2323

  import { useParamsrams } from 'next/navigation';
  const uParams = useParams ()
  <p>{uParams.clientside}</p>

🔹 Pathname: /learn-how-get-url-data/2323

Use usePathname() to get the current route path.

'use client'
import { usePathname } from 'next/navigation';

const Component = () => {
  const pathname = usePathname();
  console.log(pathname);
  return <div>{pathname}</div>;
};

🔹 Search Params: name=zohaib

Name Param: zohaib

useSearchParams() is used to read query strings on the client side.

import { useSearchParams } from 'next/navigation';

const search = useSearchParams();
console.log(search.toString()); // Converts to a string
console.log(search.get('name')); // Get specific query param

const name = search.get('name');