GoogleChromeLabs / GoogleChromeLabs/quicklink

feat: support `withQuicklink` HoC in ssr mode

Open
#237 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11.3k
Forks
429
PR merge metrics
No merged PRs in 30d

Description

Hey guys,

Currently `withQuicklink` component will only be used in browser but it will crash in ssr mode. Casue we bundle `prefetch` module:

https://github.com/GoogleChromeLabs/quicklink/blob/2b3dc21697550b332b2f99e7c4105f73a615d0be/src/react-chunks.js#L19

and `prefetch` module runs `hasPrefetch` method which we use `document.createElement` unsafely:

https://github.com/GoogleChromeLabs/quicklink/blob/2b3dc21697550b332b2f99e7c4105f73a615d0be/src/prefetch.mjs#L85

It is really hard to modify current `prefetch` module design to support ssr mode. How about we asynchronously import `quicklink` from CDN for `withQuicklink` component. This will prevent crash in ssr mode when use `withQuicklink`.

PR is on the way if you are ok for the this change.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.