Gatsby
هذا المحتوى غير متوفر بلغتك بعد.
Gatsby generates static HTML at build time and rehydrates on the client. CDN scripts must be loaded in browser APIs only — gatsby-browser.js is the right place.
@wink/elements npm package Install and load the CDN bundle with TypeScript types.
Install
Section titled “Install”npm install @wink/elementsLoad via gatsby-browser.js
Section titled “Load via gatsby-browser.js”The onClientEntry API runs once as soon as Gatsby’s runtime initialises in the browser:
import { load } from '@wink/elements';
export function onClientEntry() { load({ clientId: process.env.GATSBY_WINK_CLIENT_ID });}Environment variables
Section titled “Environment variables”Gatsby exposes only variables prefixed with GATSBY_ to the browser bundle:
GATSBY_WINK_CLIENT_ID=your-client-idGATSBY_WINK_CLIENT_ID=your-client-idUse in pages and components
Section titled “Use in pages and components”import React from 'react';
export default function HotelsPage() { return ( <main> <wink-content-loader layout="HOTEL" id="YOUR_LAYOUT_ID" /> <wink-lookup /> </main> );}TypeScript
Section titled “TypeScript”Gatsby uses React, so add the same JSX intrinsic declarations as the React integration:
// See /integrations/react for the full declaration filegatsby-ssr.js — no changes needed
Section titled “gatsby-ssr.js — no changes needed”You do not need to modify gatsby-ssr.js. The <wink-*> tags render as plain HTML elements in the static output, and the CDN script upgrades them when the browser loads the page.