# get-dom-document

> Get a [DOM document](https://developer.mozilla.org/en-US/docs/Web/API/Document) in both Node.js and the browser environment.

Latest version **0.1.3** (published 2022-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-dom-document
pnpm add get-dom-document
yarn add get-dom-document
bun add get-dom-document
```

## 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.1.3 |
| Published | 2022-10-17 |
| First published | 2022-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ocavue |
| Maintainers | ocavue |

## Links

- npm: https://www.npmjs.com/package/get-dom-document
- Repository: https://github.com/ocavue/get-dom-document
- Issues: https://github.com/ocavue/get-dom-document/issues
- Funding: https://github.com/sponsors/ocavue
- npm.io page: https://npm.io/package/get-dom-document

## Recent versions

- 0.1.3 (latest) — 2022-10-17
- 0.1.2 — 2022-10-14
- 0.1.1 — 2022-09-23
- 0.1.0 — 2022-09-22

## README

# get-dom-document

Get a [DOM document](https://developer.mozilla.org/en-US/docs/Web/API/Document) in both Node.js and the browser environment.

`getDomDocument` will firstly try to get the DOM document from the global `document` object. If it is not available, it will try to create a new DOM document using [`jsdom`](https://github.com/jsdom/jsdom) in Node.js environment. If `jsdom` is not available or it's not running in Node.js environment, it will return `null`.

This package use the `browser` field in `package.json` and [conditional exports](https://nodejs.org/docs/latest-v16.x/api/packages.html#conditional-exports) to provide different implementations for Node.js and the browser environment.

## Install

```
npm install get-dom-document
```

## Usage

CommonJS:

```js
const { getDomDocument } = require("get-dom-document");

const document = getDomDocument();
```

ES module:

```js
import { getDomDocument } from "get-dom-document";

const document = getDomDocument();
```

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