SazitoSazito SDKv1.4.0
API Reference

Entity Routes

Resolve URL paths to concrete storefront entities.

Method

Resolve

Use: entityRoutes.resolve(urlPart, options?).

ParameterTypeRequiredDescription
urlPartstringRequiredURL path (e.g. /product/shoe-123).
optionsRequestOptionsOptionalPer-request controls.

Returns: SazitoResponse<EntityRouteResponse>.

Product entities use the Product detail shape. The SDK places the resolved entity ID in entityId and omits it from entity.

Use products.get() for product pages and this method to resolve category, CMS, and blog paths. Pass a full path to entityRoutes.resolve(). products.get() accepts a slug or product path and returns the product alone, including taxonomy when the store assigned one. Product routes omit taxonomy.

Narrow the response by entityType before reading entity-specific fields:

const response = await client.entityRoutes.resolve('/category/shoes');
if (response.error) {
  // Render the request error.
} else if (response.data.entityType === 'product_category') {
  const route = response.data;
  const { name, description, productsCount } = route.entity;
  // Render the category information using route.entityId as its ID.
}

EntityRouteResponse fields

FieldTypeRequiredDescription
entityType'product' | 'product_category' | 'cms_page' | 'blog_page' | 'unknown'RequiredResolved entity type discriminator.
entityIdnumberRequiredResolved entity ID.
urlstringRequiredResolved URL path.
entityProduct | ProductCategory | CmsPage | BlogPageOptionalPresent when entityType is not unknown.

Examples

// app/lib/sazito-client.ts
import { createSazitoClient } from '@sazito/client-sdk';

export const sazito = createSazitoClient({
  domain: process.env.NEXT_PUBLIC_SAZITO_DOMAIN!,
});
// app/[lang]/(home)/page.tsx
'use client';
import { useEffect, useState } from 'react';
import { sazito } from '@/app/lib/sazito-client';

export default function Example() {
  const [data, setData] = useState<any>(null);

  useEffect(() => {
    sazito.entityRoutes.resolve('/product/sample-product').then((res) => setData(res.data ?? null));
  }, []);

  return <pre>{JSON.stringify(data, null, 2)}</pre>;
}

Type Details

The following tables are generated from SDK TypeScript types and include nested object fields.

EntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired

ProductEntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired
entityType'product'Required
entityProductRequired

ProductCategoryEntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired
entityType'product_category'Required
entityProductCategoryRequired

CMSPageEntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired
entityType'cms_page'Required
entityCmsPageRequired

BlogPageEntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired
entityType'blog_page'Required
entityBlogPageRequired

UnknownEntityRoute

Source: src/types/entity-route.ts

FieldTypeRequired
entityTypeEntityTypeRequired
entityIdnumberRequired
urlstringRequired
entityType'unknown'Required
entityneverOptional

EntityRouteResponse

Source: src/types/entity-route.ts

Type: \| ProductEntityRoute \| ProductCategoryEntityRoute \| CMSPageEntityRoute \| BlogPageEntityRoute \| UnknownEntityRoute

On this page