X Enterprises
Composables

useRestaurant

Fetches and exposes all data for a single restaurant by slug — profile, schema, reviews, FAQs, menu, and photos.

useRestaurant

Individual restaurant data composable. Accepts a slug and returns scoped fetch methods for every data type associated with that restaurant. Each method internally wraps $fetch in a useAsyncData call keyed by ${slug}-${resource} so results are cached and deduplicated per slug.

URL convention: endpoints resolve to ${apiEndpoint}/public/restaurants/${slug}/${resource} (note: this is the per-restaurant path, not the per-domain path used by useDomain()).

Usage

const {
  getRestaurant,
  getRestaurantSchema,
  getRestaurantReviews,
  getRestaurantFAQs,
  getRestaurantMenu,
  getRestaurantPhotos,
} = useRestaurant(slug)

Parameters

ParameterTypeDescription
slugstringThe restaurant slug, typically from useRoute().params.slug.

Returns

KeyTypeDescription
getRestaurant() => Promise<Ref<RestaurantApiResponse | null>>Fetches the full restaurant profile object.
getRestaurantSchema() => Promise<Ref<unknown>>Fetches JSON-LD structured data (schema.org) for the restaurant.
getRestaurantReviews() => Promise<Ref<Review[] | null>>Fetches the review list for the restaurant.
getRestaurantFAQs() => Promise<Ref<FAQ[] | null>>Fetches FAQ entries for the restaurant.
getRestaurantMenu() => Promise<Ref<MenuSection[] | null>>Fetches the full menu (sections and items) for the restaurant.
getRestaurantPhotos() => Promise<Ref<Photo[] | null>>Fetches the photo gallery for the restaurant.

Note: the built-in restaurants/[slug].vue layout uses useDomain().getRestaurantBySlug() directly (via useAsyncData) and provide()s the result to child pages. useRestaurant() is the standalone variant for custom pages that need the full per-restaurant resource bundle.


AI Context

composable: useRestaurant
package: "@xenterprises/nuxt-x-restaurants"
use-when: >
  Fetching data for a single restaurant profile page or any of its child
  pages (menu, reviews, photos, articles). Each method is cached per slug
  via useAsyncData, so prefer calling once at the layout level and
  passing the result down, rather than calling useRestaurant in multiple
  child components.
Copyright © 2026