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

@loadable/server

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loadable/server

Server utilities for loadable.

  • 5.16.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126K
decreased by-4.95%
Maintainers
2
Weekly downloads
 
Created

What is @loadable/server?

@loadable/server is a package that provides server-side rendering (SSR) support for code-splitting with @loadable/components. It allows you to preload and render components on the server, ensuring that the necessary chunks are sent to the client for hydration.

What are @loadable/server's main functionalities?

Server-Side Rendering

This feature allows you to collect and render chunks on the server side. The `ChunkExtractor` is used to collect all the chunks needed for the server-rendered application, ensuring that the client receives the necessary scripts for hydration.

const { ChunkExtractor } = require('@loadable/server');
const statsFile = path.resolve(__dirname, 'loadable-stats.json');
const extractor = new ChunkExtractor({ statsFile });
const jsx = extractor.collectChunks(<App />);
const html = ReactDOMServer.renderToString(jsx);

Preloading Chunks

This feature allows you to preload chunks by generating script tags for the chunks that need to be loaded. The `getScriptTags` method returns the necessary script tags to be included in the HTML sent to the client.

const { ChunkExtractor } = require('@loadable/server');
const statsFile = path.resolve(__dirname, 'loadable-stats.json');
const extractor = new ChunkExtractor({ statsFile });
const scriptTags = extractor.getScriptTags();

Style Tags

This feature allows you to collect and render style tags for the chunks. The `getStyleTags` method returns the necessary style tags to be included in the HTML sent to the client, ensuring that styles are correctly applied.

const { ChunkExtractor } = require('@loadable/server');
const statsFile = path.resolve(__dirname, 'loadable-stats.json');
const extractor = new ChunkExtractor({ statsFile });
const styleTags = extractor.getStyleTags();

Other packages similar to @loadable/server

Keywords

FAQs

Package last updated on 20 Apr 2024

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