react-ogp

The ultimate React OpenGraph component


Keywords
react, ogp, opengraph, seo, meta, reactjs, react-component, react-, opengraph-data, react-component-library
License
MIT
Install
npm install react-ogp@0.0.3

Documentation

react-ogp

Vulnerabilities Version Last commit Minified size Downloads

The ultimate React OpenGraph component.

Features

  • Automatically sets url / secure_url for images and videos.
  • TypeScript support
  • Forcing to complete all properties for an object not to forget to fill some fields

Install

pnpm i react react-ogp

Usage

Next.js

import React from 'react'
import { OGP } from 'react-ogp'
import Head from 'next/head'

export default function Index() {
  return (
    <>
      <Head>
        <OGP
          url="https://example.com"
          title="My website"
          description="This is my website"
          siteName="example.com"
          image="http://example.com/cover.jpg"
        />
      </Head>
    </>
  )
}

React Helmet

import React from 'react'
import { OGP } from 'react-ogp'
import { Helmet as Head } from 'react-helmet'

export default function Index() {
  return (
    <>
      <Head>
        <OGP
          url="https://example.com"
          title="My website"
          description="This is my website"
          siteName="example.com"
          image="http://example.com/cover.jpg"
        />
      </Head>
    </>
  )
}