New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-remarkify

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-remarkify

A simple React.js utility to convert Markdown into React components.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

react-remarkify

A lightweight React.js utility to transform Markdown into React.js components seamlessly.

Features

  • Effortlessly converts Markdown into React.js components.
  • Simple and user-friendly API.
  • Fully customizable.
  • Supports plugins for enhanced functionality.

Installation

Install react-remarkify using your preferred package manager:

# Using npm:
npm install react-remarkify --save

# Using Yarn:
yarn add react-remarkify

# Using pnpm:
pnpm add react-remarkify

# Using Bun:
bun add react-remarkify

Usage

react-remarkify provides two primary methods to incorporate Markdown into your React.js applications: the useRemark hook and the <Remark> component.

useRemark Hook

Use the useRemark hook to transform Markdown content into React.js components dynamically:

import React from "react";
import { useRemark } from "react-remarkify";

export default function App() {
  const reactContent = useRemark({ markdown: "# Hello World\nThis is **useRemark** hook" });

  return reactContent;
}

<Remark> Component

Use the <Remark> component for a declarative approach:

import React from "react";
import Remark from "react-remarkify";

export default function App() {
  const markdown = `# Hello World\nThis is a **Remark** component`;

  return <Remark>{markdown}</Remark>;
}

API Reference

useRemark Hook

The useRemark hook accepts the following parameters:

ParameterTypeRequiredDefaultDescription
markdownstringYes-The Markdown content to be converted into React.js components.
rehypePluginsPluggableListNo-Plugins for rehype to extend functionality.
rehypeReactOptionsRehypeReactOptionsNo-Options for customizing the generated React.js components.
remarkParseOptionsRemarkParseOptionsNo-Parsing options for remark.
remarkPluginsPluggableListNo-Plugins for remark to enhance Markdown processing.
remarkToRehypeOptionsRemarkRehypeOptionsNo-Options for the remark to rehype transformation.
onErrorFunctionNoconsole.errorCallback to handle errors during the Markdown-to-React conversion process.

Note: All options except markdown are now immutable once set. This decision was made for performance optimization.

<Remark> Component

The <Remark> component accepts the same options as useRemark, but you pass the markdown content as its children:

<Remark>{markdown}</Remark>

Types

PluggableList

import { PluggableList } from "unified";

RehypeReactOptions

import { Components } from "hast-util-to-jsx-runtime";
type RehypeReactOptions = { components?: Partial<Components> };

RemarkParseOptions

import { Options } from "remark-parse";
type RemarkParseOptions = Options;

RemarkRehypeOptions

import { Options } from "remark-rehype";
type RemarkRehypeOptions = Options;

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 16 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc