Skip to main content
Version: 0.0.3

Setup

Import the stylesheet once, then wrap your tree in two providers: NoughtyToursProvider supplies the client, I18nProvider supplies the language.

import {
NoughtyToursController,
NoughtyToursProvider,
I18nProvider,
ToursList
} from "@thenoughtyfox/noughty-tours-web-sdk";

import "@thenoughtyfox/noughty-tours-web-sdk/style.css";

const NTController = new NoughtyToursController({ getBearerToken });

export function App() {
return (
<NoughtyToursProvider client={NTController}>
<I18nProvider defaultLocale="en">
<ToursList onSelect={tour => navigate(`/tours/${tour.id}`)} />
</I18nProvider>
</NoughtyToursProvider>
);
}
Each component fills the viewport

They are page-level screens, sized to the full window height — give each one its own route rather than embedding it in an existing layout.

NoughtyToursProvider​

Required. Supplies the client every component reads through, and sets up the internal query cache. A component rendered outside this provider throws.

PropTypeDescription
client (required)NoughtyToursControllerThe client instance. Create it once, outside your component tree.
children (required)ReactNodeYour application.

I18nProvider​

Required. Supplies the active language. English, Romanian, Russian and German ship built in.

PropTypeDescription
children (required)ReactNodeYour application.
defaultLocaleLocaleStarting language when uncontrolled. Defaults to "en".
localeLocalePass to control the language yourself. The built-in switcher then reports through onLocaleChange instead of changing it directly.
onLocaleChange(locale: Locale) => voidFires when the user picks a language.
messagesPartial<Record<Locale, Dict>>Overrides for individual strings, merged over the built-in set.
note

The SDK never writes to storage. To remember a choice across visits, persist it from onLocaleChange and feed it back through locale.

See Localisation for building your own picker and overriding strings.

The four screens​

ComponentReadsPage
ToursListtours.list()Reference
TourManagertours.get(id)Reference
Viewertours.get(id)Reference
PublicViewertours.getBySlug(slug)Reference