Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-live

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-live

A production-focused playground for live editing React code

  • 1.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
153K
increased by11.38%
Maintainers
2
Weekly downloads
 
Created

What is react-live?

react-live is a React component that enables you to render live, editable code samples in your application. It provides a live code editor and preview, making it ideal for documentation, tutorials, and interactive coding environments.

What are react-live's main functionalities?

Live Code Editing

This feature allows users to edit code in a live editor and see the results immediately. The LiveProvider component wraps the code, and LiveEditor, LiveError, and LivePreview components handle the editing, error display, and preview respectively.

import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';

const code = `<strong>Hello World!</strong>`;

function App() {
  return (
    <LiveProvider code={code}>
      <LiveEditor />
      <LiveError />
      <LivePreview />
    </LiveProvider>
  );
}

export default App;

Custom Scope

This feature allows you to provide custom components and variables to the live code editor. By passing a scope object to the LiveProvider, you can use external components and libraries in the live code.

import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
import { Button } from 'my-ui-library';

const code = `<Button>Click me</Button>`;

const scope = { Button };

function App() {
  return (
    <LiveProvider code={code} scope={scope}>
      <LiveEditor />
      <LiveError />
      <LivePreview />
    </LiveProvider>
  );
}

export default App;

Theming

This feature allows you to apply custom themes to the live code editor. By passing a theme object to the LiveProvider, you can style the code editor to match your application's design.

import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live';
import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism';

const code = `<strong>Hello World!</strong>`;

function App() {
  return (
    <LiveProvider code={code} theme={dracula}>
      <LiveEditor />
      <LiveError />
      <LivePreview />
    </LiveProvider>
  );
}

export default App;

Other packages similar to react-live

Keywords

FAQs

Package last updated on 16 Jun 2017

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