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

ts-react-codepen-embed

v0.4.0

Published

React component to embed codepen project, in typescript and with responsive height

Readme

ts-react-codepen-embed

NPM Known Vulnerabilities Build Status Coverage Status

React component for embedding pens from Codepen.io, with responsive height and ability to embed multiple pens in the same page this time

TL;DR

This is a fork of shettypuneeth/react-codepen-embed, which is a great library to embed our Codepen project as a Component in our React app.

However, I need the following few features as well so I had decided to work on top of the above:

  • [ ] Responsive Height for the embedded pens
    • So that the height is proportional to the window width and, in my humble opinion, looks better
  • [x] Allowing the embedding of multiple pens without firing the Codepen scripts multiple times
    • Otherwise some of the scripts would fail and refuse to render
  • [x] Migrate the source to TypeScript
    • Personal preference but I think TypeScript rules :-)
  • [ ] Added automated tests coverage
  • [ ] Reinventing the wheel

Installation

#using npm cli
npm install --save ts-react-codepen-embed

#using yarn
yarn add ts-react-codepen-embed

Usage

import React from "react";
import Codepen from "ts-react-codepen-embed";

const CodepenEmbedded = () => {
  return <Codepen hash="JyxeVP" user="shettypuneeth" />;
};

Component Props

| Property | Type | Required | Default | Description | | ---------------- | --------- | -------- | ------------ | -------------------------------------------------------------- | | hash | string | true | | Id of the pen to embed | | user | string | true | | Codepen username | | height | number | false | 300 | Height of the pen | | loader | element | false | | Loader to render while the pen is being embedded or errors out | | defaultTab | string | false | css,result | Default tab to display | | themeId | string | false | dark | Theme for the pen | | preview | boolean | false | true | Make the preview "Click-to-Load" | | title | string | false | | Title of the pen | | shouldLoadScript | boolean | false | true | To load the codepen embed script or not | | overrideAsLoaded | boolean | false | | To override the loaded state |

API

Props.loader

Compenent to render when the pen is being embedded or when it errors.

<Codepen
  hash="JyxeVP"
  user="shettypuneeth"
  loader={() => <div>Loading...</div>}
/>

The loader component will receive a isLoading prop when it is, obviously, loading

const Loading = props => {
  if (props.isLoading) {
    return <div>Loading...</div>;
  } 
};

If the embed fails then the loader component will receive an error prop

const Loading = props => {
  if (props.error) {
    return <div>Error</div>;
  }
  return <div>Loading...</div>;
};

Acknowledgement

This repository is forked from shettypuneeth/react-codepen-embed so kudos to shettypuneeth. :)