Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React router link - how to navigate to absolute path

import { Link } from 'react-router-dom';
...
const Button = () => {
  <Link to="SOME_S3_URL"/>
   <button>Go to S3 URL</button>
  </Link>
}

When I click it, it's not working. Is it possible to do so?

like image 281
CCCC Avatar asked Oct 29 '25 19:10

CCCC


1 Answers

I guess SOME_S3_URL is referring to an URL to Amazon S3, which in that case, is outside of your application.

So you should use a normal <a/> instead since <Link /> is designed for internal navigation.

As for your comment about "creating a reusable button", you just apply CSS to the <a /> element so that it will look like a button. This is a common practice used by multiple popular UI libraries like MUI and Chakra UI.

like image 135
Matthew Kwong Avatar answered Nov 01 '25 08:11

Matthew Kwong