useRestaurant
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
| Parameter | Type | Description |
|---|---|---|
slug | string | The restaurant slug, typically from useRoute().params.slug. |
Returns
| Key | Type | Description |
|---|---|---|
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].vuelayout usesuseDomain().getRestaurantBySlug()directly (viauseAsyncData) andprovide()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.
useMenuCard
Reads menu card configuration from app.config.ts and exposes helpers for dietary tags, item tags, and price formatting.
useAnalytics
Client-side analytics event tracking — page views, click-throughs, FAQ views, and search impressions/clicks. Failures are swallowed so analytics never break the UI.
