AI Workshop: learn to build apps with AI →
Recipes: Next.js, how to open a link in a new window

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


Here’s how you can open a link in a new window in Next.js:

<Link href={url}>
  <a target="_blank">Click this link</a>
</Link>

You first wrap the a tag in a Link component (the Link component provided by Next.js, and inside the a tag you add a target="_blank" attribute, just like you’d do in plain HTML.

The href attribute stays on the Link component, to play well with client-side routing.

Lessons in this unit:

0: Introduction
1: Using the router to detect the active link in Next.js
2: Next.js Email Authentication using NextAuth
3: How to force a page refresh in Next.js
4: How to add Google Analytics 4 to Next.js
5: ▶︎ Next.js, how to open a link in a new window
6: How to parse Markdown in Next.js
7: How to add ReCaptcha to a Next.js form
8: How to upload files in a Next.js form