noreferrer and Referrer Policy
Every time a visitor clicks a link, or a page loads an image or a script, the browser may tell the destination where the request came from. That information is called the referrer, and you can control it. The tool most people meet first is rel="noreferrer", and behind it sits a small, useful system called Referrer Policy.
The link-focused basics are in Link Security. This lesson goes deeper into the referrer itself: what is sent, why it matters, and the controls you have.
What You Will Learnβ
- What the referrer is, and why the header is spelled
Referer - What a browser sends by default
- What
rel="noreferrer"does, and what it also implies - The eight referrer policy values
- Four ways to set a policy, and which wins
- Why secrets must never live in URLs
- The trade-offs for analytics and embeds
The Big Ideaβ
A referrer is a postcard that travels with the request, saying "I came from this page". Sometimes that is helpful. Sometimes it reveals more than you intend, such as a private path or a token in the address. Referrer Policy lets you decide how much goes on the postcard.
- The Code
- Referrer Lab
- Policy Picker
<!-- One link: send no referrer -->
<a href="https://sensitive.example.org/" rel="noreferrer">Visit the site</a>
<!-- One link: choose a specific policy -->
<a href="https://partner.example.com/" referrerpolicy="origin">Partner</a>
<!-- Images, scripts, iframes and more accept it too -->
<img src="https://cdn.example.net/logo.png" alt="Logo" referrerpolicy="no-referrer">
<!-- Whole page, in the head -->
<meta name="referrer" content="strict-origin-when-cross-origin">
Referrer-Policy: strict-origin-when-cross-origin
| Policy | What the destination receives |
|---|---|
no-referrer | nothing |
no-referrer-when-downgrade | https://shop.example.com/account/orders?id=4821&token=abc123 |
origin | https://shop.example.com/ |
origin-when-cross-origin | https://shop.example.com/ |
same-origin | nothing |
strict-origin | https://shop.example.com/ |
strict-origin-when-cross-origin (common default) | https://shop.example.com/ |
unsafe-url | https://shop.example.com/account/orders?id=4821&token=abc123 |
This address contains token in its query. Any policy that sends the full address would hand that value to the destination. Keep secrets out of URLs.
The part after # is never sent. A simplified model of the rules in the Referrer Policy specification.
Scenario 1 of 4: A password reset page. Its address holds a one-time code, and the page loads a logo and a link from other sites.
What Is the Referrer?β
When a browser requests something from another site, it can add a header named Referer that holds the address of the page making the request. The spelling is a historical typo in the original web standard, and it stuck, so the header is Referer while the policy and the attribute use the correct spelling, "referrer". JavaScript can read the same value from document.referrer.
The destination can use it for good reasons, such as analytics, "back to where you came from" features, and basic checks on where requests come from. It can also learn things you would rather keep private.
What gets sentβ
The browser may send:
- the full address, with path and query (
https://shop.example.com/account/orders?id=4821), - or the origin only (
https://shop.example.com/), - or nothing.
It never sends the part after #, and it never sends usernames or passwords from the address.
The Defaultβ
Modern browsers apply a default that is equivalent to strict-origin-when-cross-origin:
| Request goes to | What is sent |
|---|---|
| The same origin | The full address |
A different origin, still https | The origin only |
A less secure destination (https to http) | Nothing |
That is a sensible baseline. But browsers differ in age and settings, and you may want something stricter. Being explicit makes your intent clear, and protects visitors whose browsers use older defaults.
rel="noreferrer"β
Adding rel="noreferrer" to a link tells the browser not to send the Referer header for that click.
<a href="https://sensitive.example.org/" target="_blank" rel="noreferrer">Visit the site</a>
It also has a second effect: it implies noopener, so a page opened in a new tab gets no window.opener link back to yours. That second effect is the subject of noopener. The two are separate ideas that happen to arrive together.
rel="noreferrer" works on a, area, and form elements. For images, scripts, stylesheets, and iframes, use the referrerpolicy attribute instead.
Modern browsers already treat target="_blank" links as if they had noopener. They do not remove the referrer for you, because that is a separate decision. You choose it with noreferrer or a policy.
The Eight Policy Valuesβ
| Value | Same origin | Other origin (https) | Downgrade to http |
|---|---|---|---|
no-referrer | Nothing | Nothing | Nothing |
no-referrer-when-downgrade | Full address | Full address | Nothing |
origin | Origin | Origin | Origin |
origin-when-cross-origin | Full address | Origin | Origin |
same-origin | Full address | Nothing | Nothing |
strict-origin | Origin | Origin | Nothing |
strict-origin-when-cross-origin | Full address | Origin | Nothing |
unsafe-url | Full address | Full address | Full address |
Open the Referrer Lab, type a page address with a query string, and change the destination. Watch each row change. Then try the scenarios in the Policy Picker.
A quick way to choose:
- No outside party should learn anything:
no-referrer. - A good all-round default:
strict-origin-when-cross-origin. - An internal system:
same-origin. - Avoid
unsafe-url. Its name is a warning, because it sends the full address everywhere, even to insecure sites.
Four Ways to Set a Policyβ
| Where | Scope | Example |
|---|---|---|
Referrer-Policy HTTP header | The whole page, set by the server | Referrer-Policy: same-origin |
meta tag in the head | The whole page | <meta name="referrer" content="same-origin"> (written in the page's head) |
referrerpolicy attribute | One element or request | <img referrerpolicy="no-referrer"> |
rel="noreferrer" | One link, area or form | <a rel="noreferrer"> |
A setting closer to the request wins. An element's own referrerpolicy or rel="noreferrer" overrides the page-wide policy. Choose a page-wide policy first, then add exceptions only where needed.
Why This Matters: Secrets in URLsβ
The biggest referrer risk is not the policy. It is what your own URLs contain. If a page address holds a password-reset token, a session ID, an email address, or a private document path, any request that page makes can leak it through the referrer: to an analytics script, a font host, a CDN image, or a link the visitor clicks.
Rules to follow:
- Never put secrets in a URL. Send tokens in a request body or a header, or keep them in a cookie marked
HttpOnlyandSecure. - If a one-time code must be in the address, use a strict policy on that page, and exchange the code for a session and redirect away quickly.
- Avoid putting personal data in query strings. Names, emails, and IDs end up in history, server logs, and referrers.
- Set a page-wide policy so one forgotten
imgcannot leak the address.
The Referrer Lab warns you when it spots words such as token or reset in the address.
Trade-Offs to Knowβ
- Analytics. If you link out with
noreferrer, the destination site sees the visit as "direct", not as coming from you. That is the point, but you lose credit for sending traffic. Likewise, when visitors arrive at your site from places that use strict policies, your analytics may show less detail. For links you control, campaign parameters such asutm_sourcein the address are an alternative, and they are visible to the destination by design. - Embeds and APIs. Some embedded players, map keys, and image hosts check the referrer, so
no-referrercan make them fail. If an embed breaks, read the provider's documentation before loosening your policy, and useoriginrather than the full address if a check needs a site name. - Request-origin checks. Some servers use
Refererto check that a request came from their own site. Rely on proper protections instead, such as tokens andSameSitecookies, covered in Secure Forms. Separately, theOriginheader is sent on many cross-origin requests, and Referrer Policy does not control it. - Not anonymity.
noreferrerhides where the visitor came from. It does not hide their IP address, browser details, or anything else the destination can see.
Checking Your Setupβ
- Open DevTools, then Network, and click a request to another site. Under Request Headers, look for
Referer. - Check the Response Headers of your page for
Referrer-Policy. - In the Console, type
document.referreron a page you reached by a click. It shows what the browser was told. - In Elements, search for
referrerpolicyandnoreferrerto see where they are used. - Search your site for addresses that contain
token=,reset=,email=, orsession=.
Best Practicesβ
- Set a page-wide policy, and use
strict-origin-when-cross-originas a baseline. - Use
no-referrerorsame-originon pages with sensitive addresses. - Never put secrets in URLs.
- Use
rel="noreferrer"for links to sensitive or unrelated sites. - Avoid
unsafe-url. - Test embeds after tightening a policy.
- Document exceptions, and keep them rare.
- Do not rely on
Refererto protect your server.
Quick Checklistβ
- A page-wide policy is set by header or
meta - No page address contains a secret or personal data
- Sensitive pages use
no-referrerorsame-origin -
rel="noreferrer"is used where nothing should be shared - Embeds and analytics still work after the policy
- No use of
unsafe-url - The server does not depend on
Refererfor protection
Security and Privacy Notesβ
- Referrers can reveal behaviour. A destination may learn which pages of your site its visitors came from, and combine that with other data. Sending less is a privacy-friendly default.
- Visitors may have their own settings. Some browsers and extensions trim or remove referrers. Do not build a feature that breaks when the referrer is empty.
- Privacy law can apply to this data. Whether a referrer counts as personal data depends on where you operate. This is not legal advice, so check the rules that apply to you.
- Policies apply to the request, not the content. They do not stop a page from displaying private information to someone who is allowed to see it.
Global Audience Notesβ
- Privacy expectations vary by region, and strict defaults are welcome nearly everywhere.
- Some partners and payment providers need a referrer to verify the requesting site. Follow their current guidance, and prefer sending the origin only.
- Mixed
httpandhttpssites are still common in some regions. The downgrade rules above matter more there. - Language does not change anything here, but addresses can include non-English words, so use clear, neutral address paths that do not reveal personal details.
Common Mistakes to Avoidβ
- Putting tokens or emails in the address, then worrying about the policy.
- Using
noreferrerfor security and expecting it to hide a visitor's IP address. - Confusing
noreferrerwithnoopener. The first controls the header, and the second controls thewindow.openerlink. - Forgetting
referrerpolicyon images and scripts. - Setting
no-referrereverywhere and breaking an embed or an analytics tool. - Using
unsafe-url. - Misspelling the header or attribute. The header is
Referer. The policy isReferrer-Policy. The attribute isreferrerpolicy. - Expecting
Refererto be present, and writing code that fails without it. - Relying on
Refereras a security check on your own server. - Never testing after changing the policy.
Practice Timeβ
- In the Referrer Lab, keep the default values. Which policies send the token to the other site?
- Click "Same site". Which policies still send the full address?
- Click "A plain http site". Which policies send nothing?
- Remove
token=abc123from the address. What changes in the warning? - Complete all four scenarios in the Policy Picker.
- Open DevTools on any page, click a link to another site, and find the
Refererheader in the Network panel. - Add
<meta name="referrer" content="same-origin">to a test page, and repeat step 6. - Bonus: add
rel="noreferrer"to one link, click it, and compare the request headers.
Quick Recapβ
Click a question to check your answer.
1. What is the referrer?
The address of the page that made a request, sent in the Referer header (and readable as document.referrer), so the destination can see where the visitor came from.
2. What does rel="noreferrer" do?
It stops the browser from sending the Referer header for that link, and it also implies noopener.
3. What is a good default policy?
strict-origin-when-cross-origin: full address to the same origin, origin only to other https sites, and nothing to insecure sites.
4. Which setting wins when several are used?
The one closest to the request. An element's referrerpolicy or rel="noreferrer" overrides the page-wide header or meta tag.
5. Why must secrets stay out of URLs?
Addresses leak through referrers, history, and server logs. A token in the address can reach any site the page contacts.
6. Does noreferrer make a visitor anonymous?
No. It only removes the referrer. The destination still sees the IP address and other browser details.
Key Takeawaysβ
- The referrer tells a destination where a request came from.
rel="noreferrer"sends no referrer and also impliesnoopener.- There are eight policies. Use
strict-origin-when-cross-originas a baseline, and avoidunsafe-url. - Closest setting wins: element, then page.
- Keep secrets out of URLs. This matters more than any policy.
- Test embeds and analytics after you change a policy.
Next up: noopener, where you will learn how a new tab can reach back into the page that opened it, and how to close that door.