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

@xylabs/meta-server

v4.5.2

Published

Meta Server - adjusts meta data on index.html for served static site

Readme

logo

@xylabs/meta-server

main-build npm-badge codacy-badge codeclimate-badge snyk-badge license-badge

Table of Contents

Description

Express server for properly rendering HTML metadata on React sites when scraped/shared. Since React requires JS to execute in order to manipulate the DOM, page content and HTML metadata often looks different when viewed in a browser vs when scraped/shared. Likewise, client routes created via the History pushState API are client-side only and will return Not Found when requested to the server. The MetaServer attempts to ensure that shared/scraped links render the HTML just as it would be rendered when viewed in the browser. This is accomplished by intercepting route requests and rendering the HTML in headless Chrome then returning the resultant HTML instead of the typical React-hosting flow of just redirecting to the root of the site.

Install

The package should be installed under dependencies (not under devDependencies) as the server will be used for hosting & running the React App.

Using npm:

npm i --save @xylabs/meta-server

Using yarn:

yarn add @xylabs/meta-server

Usage

Development

The build output can be hosted/served via the MetaServer by running the included script. Configuration is available via

npm run start-meta
yarn start-meta

You can configure the root directory from which your app is served via the ENV VAR SERVE_DIRECTORY which defaults to './build' if not supplied

Deployment

To allow for containerized deployment the included script docker-build is provided which creates a production build of the app and outputs a container with the Meta Server which proxies the built app.

Client

  • Add xy.config.json to the root of your build output (see sample below)

Sample xy.config.json

{
  liveShare: {
    exclude: ['/exclude/*'],
    include: ['/live-share-route/*'],
  },
}

Live Share

For LiveShare routes, pages are required to provide a meta tag with the property xyo:og:image with a content attribute that contains the URL of the preferred route for rendering the preview. The URL specified for the preview must be valid and lead to a route where an element with the ID 'preview-container' is present. The MetaServer wil:

  • render the page rendered
  • read the xyo:og:image attribute
  • navigate to the URL provided in the xyo:og:image attribue
  • wait for the DOM to contain an element with the ID preview-container
  • snapshot the page and cache the image
  • update the document head to point to the og:image (and associated properties like height/width) to point to the cached snapshot

HTTP Status Codes from React (Soft 404s)

By default, meta-server returns HTTP 200 for all SPA routes, even if the React app renders a "not found" page. To return a true HTTP status code (e.g. 404) for soft error pages, add an xy:status meta tag in your React app's error page:

<meta name="xy:status" content="404" />

For example, in a React component:

function NotFoundPage() {
  return (
    <>
      <Helmet>
        <meta name="xy:status" content="404" />
      </Helmet>
      <h1>Page Not Found</h1>
    </>
  )
}

When meta-server renders the page via Puppeteer (in Dynamic Share mode), it reads this meta tag and returns the specified HTTP status code instead of 200. This only applies to hard navigations (direct URL access, page refresh); client-side route changes within the SPA are unaffected.

Requirements:

  • The route must be handled by Dynamic Share (configured via dynamicShare.pathFilter in xy.config.json). Dynamic Share uses Puppeteer to render the page, which is required to detect the meta tag.
  • Live Share and Proxy Original modes do not support xy:status because they do not perform a full page render.

Supported status codes: Any valid HTTP status code (404, 410, 301, etc.)

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XY Labs