npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@opacedev/preferred-source-element

v1.0.0

Published

Add as Preferred Source Button & Popup for Google (SEO & AI Overviews) web component for plain HTML and frameworks, with SSR safety and deeplink fallback.

Readme

Add as Preferred Source Button & Popup for Google (SEO & AI Overviews) — web component

Add as Preferred Source Button & Popup for Google (SEO & AI Overviews)

Preferred Sources button variants in light and dark themes

Variant gallery: the web component is the rendered control used for each presentation.

<preferred-source-button> brings the official popup trigger, deeplink fallback and ps-click event to plain HTML, Angular and other HTML-capable frameworks.

Install from npm with npm i @opacedev/preferred-source-element.

Why publishers use Preferred Sources

The button gives a reader a direct route to choose the publication in Google. Google says fresh and relevant content from a selected source is more likely to appear in that reader's Top Stories and may receive a preferred badge in AI Mode and AI Overviews. Google also reports roughly twice the click-through after a user selects a source.

That is personalisation for the individual reader, not a site-wide ranking factor or a guarantee of traffic, inclusion or AI citations. Read Google's guidance and click-through finding.

Use from this repository

pnpm install
pnpm --filter @opacedev/preferred-source-element build
import "@opacedev/preferred-source-element/register";
<preferred-source-button
  theme="dark"
  variant="google-colours"
></preferred-source-button>

Listen for ps-click to record a trigger click. ps-ready reports SDK readiness; ps-fallback reports that the element changed to Google's deeplink because the SDK was blocked or did not render.

Attributes and limits

theme, lang, mode, label, variant, domain, href-fallback, disabled and render-timeout are supported. mode="manual" is the default for dynamic UI. mode="auto" lets Google's renderer use the attributed light-DOM element and falls back if no button appears.

| Attribute | Default | Purpose | | -------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------- | | theme / lang | light / browser language | Passed to the documented SDK configuration. | | mode | manual | auto renders Google's attributed target; manual mode renders this component's trigger. | | label / variant | Default label / google-default | Sets visible text and one of google-default, google-colours or neutral. | | domain / href-fallback | Current hostname / computed link | Sets the preferred hostname or an explicit fallback URL. | | disabled | Absent | Prevents trigger activation. | | render-timeout | 4000 ms | Auto-mode time allowed after SDK load before a no-render fallback. |

| Event | Meaning | | ------------- | ------------------------------------------------------------------------------------- | | ps-click | A user activated the trigger; its detail includes mode, theme, language and domain. | | ps-ready | The SDK is ready for the selected mode. | | ps-fallback | The component switched to the deeplink because the SDK was blocked or did not render. |

The component uses a native button or link, visible focus styles and reduced-motion handling. Validate contrast when overriding --ps-* properties. It is safe to import in SSR bundles, but server output remains an unknown custom element until client hydration.

Style with --ps-bg, --ps-colour, --ps-radius, --ps-font-family, --ps-hover-bg, --ps-lift and --ps-focus-ring, or with ::part(button), ::part(fallback) and ::part(container).

Limitation. Google's SDK has no completion callback or event. ps-click measures a trigger click, not a confirmed addition.

External service and troubleshooting

Browser use loads Google's publisher script. The element does not send ps-click anywhere or store event records; your application chooses whether to listen. When ps-fallback fires, keep the rendered link, then check consent, CSP, the configured domain and any overridden render-timeout before expecting Google's button.

See the live demo and the root README for requirements, privacy and troubleshooting.


Source: suite repository · Support: GitHub issues · Product hub · Opace SEO services · Opace on GitHub · MIT licence