Coder Social home page Coder Social logo

New tabs about wouter HOT 4 CLOSED

molefrog avatar molefrog commented on April 30, 2024
New tabs

from wouter.

Comments (4)

molefrog avatar molefrog commented on April 30, 2024

Hey @kthyer, so you mean like having something like <a target="_blank"> in your code? You should be able to pass any parameters that a regular link supports:

import { Link } from "wouter";

<Link href="/app" target="_blank" />

Please let me know if that works.

Important security note: keep in mind to use rel="noopener noreferrer" when creating target="_blank" links. This little trick will save your users from potential Tab Nabbing attack.

from wouter.

kthyer avatar kthyer commented on April 30, 2024

I don't think it works with the Link component. I can get it to work on a normal <a target="_blank">.

Here's what I tried:

<Link href="/app" target="_blank" rel="noopener noreferrer">
Test
</Link>

from wouter.

molefrog avatar molefrog commented on April 30, 2024

@kthyer I see now... It doesn't work indeed, because the Link is designed to intercept clicks and perform a pushState navigation. I don't think you actually need a Link here, since the component is mostly pointless in this case. So I suggest you just go with a plain link.

By the way, not directly related, but there is a support for opening a link in a new tab when control key is pressed:
https://github.com/molefrog/wouter/blob/master/index.js#L93

So in your case what you need is a Link which always ignores the click handler, but then it just becomes a regular a component. If you're looking for more complicated logic you can always extend the link using component composition.

from wouter.

pruthvip15 avatar pruthvip15 commented on April 30, 2024

Hi @molefrog and the wouter community. Thanks a lot for all your efforts with this library.

I had a question,
I was thinking should this issue/resolution be part of the docs with the Link component.

from wouter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.