npm package
هذا المحتوى غير متوفر بلغتك بعد.
The @wink/elements npm package is the quickest way to add Wink web components to any JavaScript or TypeScript project. It provides a load() function that injects the CDN resources and full TypeScript type declarations for all component attributes.
wink-travel/wink-elements on GitHub Source code, API reference, and contribution instructions.
Install
Section titled “Install”npm install @wink/elementsQuick start
Section titled “Quick start”Call load() once at app startup. It is idempotent — safe to call multiple times.
import { load } from '@wink/elements';
load({ clientId: 'YOUR_CLIENT_ID' });Then use any Wink component in your HTML or JSX:
<wink-content-loader layout="HOTEL" id="YOUR_LAYOUT_ID"></wink-content-loader>Framework examples
Section titled “Framework examples”Next.js (App Router)
Section titled “Next.js (App Router)”'use client';import { useEffect } from 'react';import { load } from '@wink/elements';
export default function RootLayout({ children }: { children: React.ReactNode }) { useEffect(() => { load({ clientId: process.env.NEXT_PUBLIC_WINK_CLIENT_ID! }); }, []); return <html><body>{children}</body></html>;}Nuxt 3
Section titled “Nuxt 3”import { load } from '@wink/elements';
export default defineNuxtPlugin(() => { load({ clientId: useRuntimeConfig().public.winkClientId });});---import { load } from '@wink/elements';---<script> import { load } from '@wink/elements'; load({ clientId: import.meta.env.PUBLIC_WINK_CLIENT_ID });</script>SvelteKit
Section titled “SvelteKit”import { load as loadWink } from '@wink/elements';import { browser } from '$app/environment';
export function load() { if (browser) { loadWink({ clientId: import.meta.env.PUBLIC_WINK_CLIENT_ID }); }}TypeScript types
Section titled “TypeScript types”All component attribute interfaces are exported for use in JSX, template literals, or typed dictionaries:
import type { WinkContentLoaderAttributes, WinkLayout } from '@wink/elements';
const attrs: WinkContentLoaderAttributes = { layout: 'HOTEL', // TypeScript will catch invalid layout values id: 'abc123', sort: 'POPULARITY',};Using a staging CDN
Section titled “Using a staging CDN”load({ clientId: 'YOUR_CLIENT_ID', cdnBaseUrl: 'https://staging-elements.wink.travel',});load(options)
Section titled “load(options)”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
clientId | string | Yes | — | Your Wink OAuth2 Client ID |
configurationId | string | No | — | Optional customization ID |
cdnBaseUrl | string | No | https://elements.wink.travel | Override CDN URL |