# Booking Elements

`@ogattermayr/outdoor-grid-booking` is the booking package used by Outdoor Grid's hosted guest flow. It provides typed calls in `/core`, React hooks in `/hooks`, controlled visual parts and full flows in `/react`, CSS in `/styles.css`, and a server route in `/next`. The site keeps its own domain, navigation, words, and look.

## Install

Read access to the package is granted by Outdoor Grid. Ask the Outdoor Grid team in the chat in your shop's app.

The package is private on GitHub Packages. Add this registry configuration to the site repository's `.npmrc` and set `NPM_TOKEN` in the package install environment:

```bash
printf '%s\n' '@ogattermayr:registry=https://npm.pkg.github.com' '//npm.pkg.github.com/:_authToken=${NPM_TOKEN}' > .npmrc
pnpm add @ogattermayr/outdoor-grid-booking@0.4.5 --save-exact
pnpm add react@^19 @tanstack/react-query@^5.104
```

Read the package's CHANGELOG before changing an exact pin. The site key belongs in a server only secret named `OUTDOOR_GRID_SITE_KEY`, never in a `NEXT_PUBLIC_` variable.

## One server route

In a Next.js app deployed on Vercel, create `app/api/outdoor-grid/[op]/route.js`:

```js
import { createBookingRoute, clientIpFrom } from "@ogattermayr/outdoor-grid-booking/next";

export const { POST } = createBookingRoute({
  apiUrl: "https://api.outdoorgrid.ai",
  siteKey: process.env.OUTDOOR_GRID_SITE_KEY, // Set this on the server.
  shop: "your-shop-slug",
  clientIp: clientIpFrom.vercel,
});
```

The route accepts only its listed operations, checks the page's origin, and keeps the booking capability in an HttpOnly cookie. `clientIpFrom.vercel` is for Vercel, which supplies the trusted address. On another host, choose that host's trusted helper or pass `clientIp: null` deliberately. Payment operations require explicit opt in; see [payments and returns](/docs/booking-api/payments-and-returns).

## A controlled element

Import the package CSS once in your Next app's layout. A `PeopleStepper` accepts a value and a callback. This complete `app/book/page.jsx` shows one controlled element; use the full `GuestBookingFlow` to collect a real booking.

```js
"use client";

import { useState } from "react";
import { PeopleStepper } from "@ogattermayr/outdoor-grid-booking/react";
import "@ogattermayr/outdoor-grid-booking/styles.css";

export default function BookPage() {
  const [people, setPeople] = useState(2);
  return (
    <main>
      <h1>Book a trip</h1>
      <PeopleStepper
        label="Riders"
        sub="How many people are coming?"
        value={people}
        min={1}
        max={20}
        onChange={setPeople}
      />
      <p>{people} riders</p>
    </main>
  );
}
```

Elements expose `data-og-part` names for styling. Set the package's CSS theme tokens in the site's CSS for surfaces, type, shape, and the primary action. `BookingProvider` or `GuestBookingProvider` can also receive a theme and shop words. The full `GuestBookingFlow` accepts a router, optional shop looks, Stripe loader, and `onBooked` callback; its price and availability still come from the API. For every exported prop and part, use the [Booking Elements reference](/docs/api/booking-elements).
