Socket
Socket
Sign inDemoInstall

ssr-window

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ssr-window

Better handling for window object in SSR environment


Version published
Weekly downloads
937K
decreased by-18.93%
Maintainers
1
Install size
20.6 kB
Created
Weekly downloads
 

Changelog

Source

4.0.2 (2021-12-13)

Features

  • export package.json (#18) (8a019fb)

Readme

Source

SSR Window

Better handling for window and document object in SSR environment.

This library doesn't implement the DOM (like JSDOM), it just patches (or creates window and document objects) to avoid them to fail (throw errors) during server-side rendering.

Was created for use in:

Installation

Library available on NPM:

npm i ssr-window

Usage

import { window, document } from 'ssr-window';

window.addEventListener('resize', () => {});

const div = document.querySelectorAll('div');

Extending

If you rely on some window/document properties which are not included here, you can use extend helper to add them:

import { window, document, extend } from 'ssr-window';

// add window.navigator.language
extend(window, {
  navigator: {
    language: 'en',
  },
});

// add document.body
extend(document, {
  body: {
    /* ... */
  },
});

Contribution

Yes please! See the contributing guidelines for details.

Licence

This project is licensed under the terms of the MIT license.

Keywords

FAQs

Last updated on 13 Dec 2021

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