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

cloudflare-error

v1.0.2

Published

React component rendering the Cloudflare-style error page

Readme

Cloudflare Error React Component

A drop-in React component that renders the Cloudflare-style error page from error.ejs, packaged as an ESM module.

Installation

npm install cloudflare-error

Peer deps: React and ReactDOM (v17+). Type definitions are included via error.d.ts.

Usage

Render to string (SSR):

import React from "react";
import ReactDOMServer from "react-dom/server";
import CloudflareErrorPage from "cloudflare-error/error.mjs";

const html = ReactDOMServer.renderToStaticMarkup(
  <CloudflareErrorPage
    errorCode={521}
    title="Web server is down"
    rayId="1234abcd"
    clientIp="203.0.113.42"
    errorSource="host"
    hostStatus={{ status: "error", status_text: "Down" }}
    whatHappened="<p>The origin server refused the connection.</p>"
    whatCanIDo="<p>Please check your origin server.</p>"
  />
);

Render in a React app:

import React from "react";
import CloudflareErrorPage from "cloudflare-error/error.mjs";

export function ErrorScreen() {
  return <CloudflareErrorPage time={new Date().toUTCString()} rayId="abcd" />;
}

TypeScript example:

import CloudflareErrorPage, {
  CloudflareErrorPageProps,
  StatusDetails,
} from "cloudflare-error";

const hostStatus: StatusDetails = { status: "error", status_text: "Offline" };

export function ErrorScreen(props: CloudflareErrorPageProps) {
  return (
    <CloudflareErrorPage
      {...props}
      errorCode={520}
      title="Unknown Error"
      hostStatus={hostStatus}
    />
  );
}

Props

Top-level props override anything in params (a convenience object matching the original EJS shape).

  • errorCode (number): Error code. Default 500.
  • title (string): Heading text. Default "Internal server error".
  • htmlTitle (string): <title> tag override; falls back to "<errorCode>: <title>".
  • time (string): Timestamp shown under the header.
  • rayId (string): Ray ID in the footer.
  • clientIp (string): IP shown after reveal. Default "1.1.1.1".
  • whatHappened (string | ReactNode): Content for "What happened?"; string is injected as HTML.
  • whatCanIDo (string | ReactNode): Content for "What can I do?"; string is injected as HTML.
  • errorSource ("browser" | "cloudflare" | "host"): Highlights the matching status block.
  • moreInformation ({ link, text, for, hidden }): Controls the header link/visibility.
  • perfSecBy ({ link, text }): Footer provider link/text.
  • creatorInfo ({ link, text, hidden }): Optional footer credit.
  • browserStatus / cloudflareStatus / hostStatus:
    • { status: "ok" | "error", status_text, status_text_color, location, name }
  • params (object): Optional legacy-style object with the same keys as above (error_code, title, html_title, time, ray_id, client_ip, what_happened, what_can_i_do, error_source, more_information, perf_sec_by, creator_info, browser_status, cloudflare_status, host_status).

Notes

  • The component renders full HTML (including <html>/<head>). For client-side usage inside an existing app shell, you can copy the inner markup or wrap in your layout as needed.
  • Strings passed to whatHappened and whatCanIDo are injected via dangerouslySetInnerHTML; sanitize user input if necessary.
  • CSS is inlined to match the original Cloudflare error page.