# codemirror-ssr

> SSR compatible CodeMirror 5

Latest version **0.65.0** (published 2022-05-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install codemirror-ssr
pnpm add codemirror-ssr
yarn add codemirror-ssr
bun add codemirror-ssr
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.65.0 |
| Published | 2022-05-15 |
| First published | 2021-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rongjian Zhang |
| Maintainers | pd4d10 |

## Links

- npm: https://www.npmjs.com/package/codemirror-ssr
- Repository: https://github.com/pd4d10/codemirror-ssr
- Homepage: https://github.com/pd4d10/codemirror-ssr#readme
- Issues: https://github.com/pd4d10/codemirror-ssr/issues
- npm.io page: https://npm.io/package/codemirror-ssr

## Recent versions

- 0.65.0 (latest) — 2022-05-15
- 0.0.6 — 2021-02-24
- 0.0.5 — 2021-02-24
- 0.0.4 — 2021-02-24
- 0.0.3 — 2021-02-24
- 0.0.2 — 2021-02-23
- 0.0.1 — 2021-02-23

## README

# codemirror-ssr

SSR compatible CodeMirror 5

## Motivation

[CodeMirror 5](https://github.com/codemirror/CodeMirror) 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

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

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

### After

```js
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
  });
}
```

## Built with codemirror-ssr

- [ByteMD](https://github.com/bytedance/bytemd): A hackable Markdown editor component built with Svelte

## License

MIT

---
_Source: https://npm.io/package/codemirror-ssr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
