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

@metamanager/react-seo

v0.7.0

Published

Meta tag update & schema markup/structured data deployment

Downloads

26

Readme

Metamanager React SEO

Meta tag update & schema markup/structured data deployment for your React/Next.js frontend.

SaaS-solution for search engine optimization (SEO)

metamanager platform is connected to websites in order to update meta tags (title, description...) and insert schema markup/structured data for each internal page/URL.

As a frontend developer your can create your account and manage websites in which you want to implement this plugin... And let webmarketers doing the rest of the job: meta tag & schema markup edition...

Features

  • Meta/structured data download (secured operation)
  • Server-side rendering (SSR)
  • <title /> & <meta description /> inserted within HTML tag
  • <script application/ld+json /> inserted within body tag

Installation

You can install Metamanager React SEO via NPM:

npm i @metamanager/react-seo

Usage/Examples

Import @metamanager/react-seo in 4 steps into your React/Next.js project.

1. Wrapping your application in a SEO helmet provider

Set 3 properties for the provider:

  • context: Metamanager context
  • webSiteId: ID of the website (supplied from the platform)
  • authToken: API token (supplied from the platform)

/src/_app.ts

import { HelmetProvider } from "@metamanager/react-seo";
import { metamanagerContext } from "../context";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
    return (
        <HelmetProvider context={metamanagerContext} webSiteId={process.env.MM_WEBSITE_ID} authToken={process.env.MM_TOKEN}>
            <Component {...pageProps} />
        </HelmetProvider>
    );
}

2. Initializing an context object to store the Metamanager data

Initialize the Metamanager context here:

/src/context.ts

import { HelmetContextData } from "@metamanager/react-seo";

export const metamanagerContext : HelmetContextData={};

3. Meta tags & schema markup insertion (SSR)

Fetch & display meta tags & schema markup in the document template:

/src/_document.tsx

import { metamanagerContext } from "../context";
import { Html, Head, Main, NextScript } from "next/document";
import { ReactNode } from "react";

export default function Document() {
    render() {
        return (
            <Html lang="en">
                <Head />
                {metamanagerContext?.helmet?.title?.toComponent() as ReactNode}
                {metamanagerContext?.helmet?.meta?.toComponent() as ReactNode}
                {metamanagerContext?.helmet?.script?.toComponent() as ReactNode}
                <body>
                    <Main />
                    <NextScript />
                </body>
            </Html>
        );
    }
}

4. Page file customization

Import & insert SEO Helmet component from @metamanager/react-seo to display meta tags & schema markups for the relevant page path.

/src/pages/index.tsx

import { withMetaManagerSEO,  withMetamanagerStaticProps, MetamanagerNextPage } from "@metamanager/react-seo";

const Home: MetamanagerNextPage<{}> = ({ path, apiData}) => {
  return (
    <>
      <main>Add your components here...</main>
    </>
  );
}

export default withMetaManagerSEO(Home);

export const getStaticProps = withMetamanagerStaticProps<{}>(
    () => {
        return { props: { path: "/", } };
    }, {
        webSiteId: process.env.MM_WEBSITE_ID,
        authToken: process.env.MM_AUTH_TOKEN
    }
);

/src/pages/[...path].tsx

import { withMetaManagerSEO,  withMetamanagerStaticProps, MetamanagerPageProps } from "@metamanager/react-seo";
import { GetStaticProps } from "next";

export default function AnyPage() {
  return (
    <>
      <main>Add your components here...</main>
    </>
  );
}

export default withMetaManagerSEO(AnyPage);

export const getStaticPaths = () => {
    const pageList = new Webpage(process.env.MM_WEBSITE_ID);
    const urls = pageList.sort();
    return {
        paths: urls?.filter(i => i.url !== '/')?.map(i => ({ params: { path: i.url?.startsWith('/') ? i.url.slice(1).split('/') : i.url.split('/') } })) ?? [],
        fallback: false
    }
};

const retriveStaticProps : GetStaticProps<MetamanagerPageProps<{}>, { path : string[]}> =({ params }) => {
    return {
        props: {
            path: params?.path?.join('/')?.startsWith('/') ? params?.path?.join('/') : '/' + params?.path?.join('/')
        }
    }
};

export const getStaticProps = withMetamanagerStaticProps<{}>(retriveStaticProps, {
    webSiteId: process.env.MM_WEBSITE_ID,
    authToken: process.env.MM_AUTH_TOKEN
});

License

MIT

Subscription to the service

To make the plugin work, an account must be created in https://metamanager.io.

This platform allows users to work on meta data and schema markup which will be sent to your website. You will also receive the website ID & API token to configure the plugin.