@shopify/react-preconnect

Reduces request latency by preconnecting hosts

Usage no npm install needed!

<script type="module">
  import shopifyReactPreconnect from 'https://cdn.skypack.dev/@shopify/react-preconnect';
</script>

README

@shopify/react-preconnect

Note: This module is now deprecated. You should move to using the <Preconnect /> component from @shopify/react-html instead.

Build Status License: MIT npm version npm bundle size (minified + gzip)

Reduces request latency by preconnecting hosts

Installation

$ yarn add @shopify/react-preconnect

Usage

This library default exports a <Preconnect /> component, which adds <link />s to <head></head> for the given hosts with dns-prefetch and preconnect relations.

import Preconnect from 'react-preconnect';

...

function App(props) {
  const preconnectHosts = [
    'api.example.com',
    'example.com',
    'example2.com',
  ]

  <Preconnect hosts={preconnectHosts} />
}

Interface

export interface Props {
  hosts: string[];
}