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

codemirror-ssr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codemirror-ssr

SSR compatible CodeMirror 5

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by21.74%
Maintainers
1
Weekly downloads
 
Created
Source

codemirror-ssr

SSR compatible CodeMirror 5

Motivation

CodeMirror 5 uses some client-only APIs at top level, which makes it not compatible with SSR. A way to solve this problem is to dynamic import codemirror module and its addons in client-only lifecycles. It works, but would cause unnecessary bundle split and increase the final loading time.

Usage

Before

import codemirror from "codemirror";
import "codemirror/addon/display/placeholder";

const editor = codemirror.fromTextArea(textarea, {
  // options
});

After

import factory from "codemirror-ssr";
import usePlaceholder from "codemirror-ssr/addon/display/placeholder";

// the client-only lifecycle
function mounted() {
  const codemirror = factory();
  usePlaceholder(codemirror); // apply addons manually

  const editor = codemirror.fromTextArea(textarea, {
    // options
  });
}

FAQs

Package last updated on 24 Feb 2021

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