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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@behold/widget

v0.5.64

Published

[![Behold](https://img.shields.io/badge/Behold-e8ebd7.svg?style=for-the-badge&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjMuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcn

Downloads

27

Readme

Official Behold Widget Web Component

Behold React

This is the official Behold widget JS package. It is built using web components, which delivers a few benefits:

  1. It can be used with any JS framework (React, Svelte, Vue, Angular, Solid... you name it), or just dropped into an HTML document.
  2. It uses no framework and requires no external packages, so it's very lightweight, and won't cause dependency bloat.
  3. It uses the Shadow DOM, which provides style encapsulation.

Documentation

https://behold.so/docs/widget/

Installation

We have official wrapper components for a number of frameworks. Links below:

React Preact Svelte Vue.js Angular

Want us to add a framework to this list? Let us know what we should build next: [email protected]

For other environments, or if you just want to use the web component directly, the recommended method is including the embed script directly in your HTML, loaded from our CDN: <script src="https://w.behold.so/widget.js" type="module"></script>. In a traditional single page application, for example, you would add this script tag to your index.html file.

The reason we suggest this method over installing the NPM package is that it means your widget will always be up to date. Whenever we publish a bugfix or improvement your users will automatically benefit without any action on your part, and you have one less dependency to worry about.

There may be some cases where you will want to import this package directly. To do this, you will begin by installing the package with your favorite package manager:

NPM

npm install @behold/widget

// or
pnpm add @behold/widget

// or
yarn add @behold/widget

Usage

If you've decided to use the NPM package directly, you will need to import and register the widget before it can be used. Like so:

import { widget } from '@behold/widget'

widget.register()

Once you've either included the embed script or imported and registered your widget you can use the widget web component just like you would any HTML element:

<behold-widget feed-id="YOUR_FEED_ID"></behold-widget>

Because of how web components work, the <behold-widget> element will just be an empty HTML tag until the embed script loads or you call widget.register(), at which point your widget will render. So you don't need to worry about running the JS before including the HTML tag, and the widget simply won't load in an environment without JavaScript support.

Configuration

The Behold widget component only accepts a single attribute, feed-id, which can be found by opening your feed in the Behold dashboard and clicking on "Embed Code".

All configuration and customization is done on the Behold dashboard. When you make changes there, it will automatically update your widget, no code changes required.

Load event

This component emits a load event after its initial render.

<behold-widget
  feed-id="YOUR_FEED_ID"
  onload="console.log('loaded!')"
></behold-widget>