DEV Community

Himanshu Gupta
Himanshu Gupta

Posted on

2

basename prop in Reactjs

The basename prop is used to provide a base URL path for all the locations in the application. For example, if you want to render your application at the /admin path instead of rendering at the root path /, then specify the basename prop in :


The basename prop now adds the base URL path /admin to the application. When you navigate using and , the basename path is added to the URL. For example, consider the following code with two components:

<BrowserRouter basename="/admin">   
 <div className="component">      
  <nav>         
      <Link to="/">Home</Link>  
      <Link to="/dashboard">Dashboard</Link>  
  </nav>   
 </div>
</BrowserRouter>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay