Socket
Socket
Sign inDemoInstall

@mdx-js/runtime

Package Overview
Dependencies
164
Maintainers
4
Versions
177
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mdx-js/runtime

Parse and render MDX in a runtime environment


Version published
Maintainers
4
Install size
11.0 MB
Created

Readme

Source

@mdx-js/runtime

Build Status lerna Chat

Parse and render MDX in a runtime environment.

:warning: warning: this is not the preferred way to use MDX since it introduces a substantial amount of overhead and dramatically increases bundle sizes. It should also not be used with user input that isn’t sandboxed.

Installation

npm:

npm i -S @mdx-js/runtime

Usage

Props

The MDX Runtime component accepts two props:

NameDescription
componentsGlobally available components for the runtime
scopeVariables that are accessible in the JSX portion of the document
remarkPluginsArray of remark plugins

Example code

import React from 'react'
import MDX from '@mdx-js/runtime'

// Provide custom components for markdown elements
const components = {
  h1: props => <h1 style={{color: 'tomato'}} {...props} />,
  Demo: props => <h1>This is a demo component</h1>
}

// Provide variables that might be referenced by JSX
const scope = {
  some: 'value'
}

const mdx = `
# Hello, world!

<Demo />

<div>Here is the scope variable: {some}</div>
`

export default () => (
  <MDX components={components} scope={scope}>
    {mdx}
  </MDX>
)

Contribute

See the Support and Contributing guidelines on the MDX website for ways to (get) help.

This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Compositor and Vercel

Keywords

FAQs

Last updated on 01 Dec 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc