Pular para o conteúdo principal

Storefront Slots

Storefront slots are containers available in the storefront pages where you can render your UI components. These slots allow you to customize the shopping experience across different pages.

Available Slots

These are the slots that are available in the storefront:

SlotPage
before_main_contenthome, product, category, search
after_headerhome, product, category, search, cart
drawer_lefthome, product, category, search, cart
drawer_righthome, product, category, search, cart
before_quick_buy_add_to_carthome, category, search
before_product_grid_item_namehome, category, search
after_product_grid_item_namehome, category, search
before_product_grid_item_pricehome, category, search
after_product_grid_item_pricehome, category, search
product_grid_item_image_top_lefthome, product, category, search
product_grid_item_image_top_righthome, product, category, search
product_grid_item_image_bottom_lefthome, product, category, search
product_grid_item_image_bottom_righthome, product, category, search
before_go_to_checkouthome, product, category, search
before_product_detail_nameproduct
after_product_detail_nameproduct
before_product_detail_priceproduct
after_product_detail_priceproduct
before_product_detail_add_to_cartproduct
after_product_detail_add_to_cartproduct
after_product_descriptionproduct
before_line_itemscart
before_line_itemcart
after_cart_summarycart
after_go_to_checkoutcart
before_footerhome, product, category, search

Slot Visual Reference

Home, Category, and Search Pages

  • before_main_content

Before Main Content Slot

  • after_header

After Header Slot

  • drawer_left

Drawer Left Slot

  • drawer_right

Drawer Right Slot

  • before_go_to_checkout

Before Go to Checkout Slot

  • before_footer

Before Footer Slot

Product Grid Slots

Product grid slots are special slots that allow you to render components on product cards within product grids. These slots include:

  • product_grid_item_image_top_left
  • product_grid_item_image_top_right
  • product_grid_item_image_bottom_left
  • product_grid_item_image_bottom_right
  • before_product_grid_item_name
  • after_product_grid_item_name
  • before_product_grid_item_price
  • after_product_grid_item_price

Product Grid Slots

Rendering Components in Product Grids

To render components in product grids, return an array of components where the root element for each product includes the key prop set to that product's ID. This allows your app to render components across multiple items in the grid.

import { Text } from "@tiendanube/nube-sdk-jsx";
import type { NubeSDK } from "@tiendanube/nube-sdk-types";

export function App(nube: NubeSDK) {
const productIds = [1, 2, 3];
nube.render("product_grid_item_image_top_left", () => {
return productIds.map((id) => <Text key={id}>ID: {id.toString()}</Text>);
});
}

For a complete example of rendering components dynamically in product grids, see the Dynamic Product Grid Rendering section below:

Product Page Slots

  • before_product_detail_name
  • after_product_detail_name
  • before_product_detail_price
  • after_product_detail_price
  • before_product_detail_add_to_cart
  • after_product_detail_add_to_cart

Product Page Slots Overview

  • before_product_detail_price

Before Product Detail Price Slot

  • after_product_detail_price

After Product Detail Price Slot

  • before_product_detail_add_to_cart

Before Product Detail Add to Cart Slot

  • after_product_detail_add_to_cart

After Product Detail Add to Cart Slot

  • after_product_description

After Product Description Slot

Cart Page Slots

  • before_line_items

Before Line Items Slot

  • before_line_item

The key prop must be set to the line item's ID for each component.

export function App(nube: NubeSDK) {
nube.render("before_line_item", (state) => {
return state.cart.items.map((item) => <Text key={item.id}>Content</Text>);
});
}

Before Line Item Slot

  • after_cart_summary

After Cart Summary Slot

  • after_go_to_checkout

After Go to Checkout Slot

Examples

Adding Content to Product Page

import type { NubeSDK } from "@tiendanube/nube-sdk-types";
import { Box, Text } from "@tiendanube/nube-sdk-jsx";

export function App(nube: NubeSDK) {
nube.render("after_product_detail_name", [
<Box key="product-badge">
<Text>Free Shipping Available!</Text>
</Box>,
]);
}

Adding Content Before Add to Cart

import type { NubeSDK } from "@tiendanube/nube-sdk-types";
import { Box, Text } from "@tiendanube/nube-sdk-jsx";

export function App(nube: NubeSDK) {
nube.render("before_product_detail_add_to_cart", [
<Box key="size-guide">
<Text>View Size Guide</Text>
</Box>,
]);
}

Adding Content to Cart Page

import type { NubeSDK } from "@tiendanube/nube-sdk-types";
import { Box, Text } from "@tiendanube/nube-sdk-jsx";

export function App(nube: NubeSDK) {
nube.render("after_cart_summary", [
<Box key="cart-promo">
<Text>Add $50 more for free shipping!</Text>
</Box>,
]);
}

Dynamic Product Grid Rendering

Product Grid Slots

import { Text } from "@tiendanube/nube-sdk-jsx";
import type { NubeSDK, ProductDetails } from "@tiendanube/nube-sdk-types";
import { styled } from "@tiendanube/nube-sdk-ui";

const StyledText = styled(Text)`
color: red;
font-weight: bold;
`;

export function App(nube: NubeSDK) {
const state = nube.getState();

if (state.location.page.type === "home") {
const sections = state.location.page.data?.sections || [];
const allProducts = sections.reduce((acc: ProductDetails[], section) => {
if (section?.products && Array.isArray(section.products)) {
acc.push(...section.products);
}
return acc;
}, []);

nube.render("product_grid_item_image_top_left", () => {
return allProducts.map((product) => (
<StyledText key={product.id}>ID: {product.id.toString()}</StyledText>
));
});
}
}

This is a Dynamic Product Grid Rendering example that displays a styled badge on the top-left corner of each product image in the home page grid.

const sections = state.location.page.data?.sections || [];
const allProducts = sections.reduce((acc: ProductDetails[], section) => {
if (section?.products && Array.isArray(section.products)) {
acc.push(...section.products);
}
return acc;
}, []);

The previous code flattens all products from all sections into a single array.

nube.render("product_grid_item_image_top_left", () => {
return allProducts.map((product) => (
<StyledText key={product.id}>ID: {product.id.toString()}</StyledText>
));
});

Then, to understand the slot rendering, key={product.id} is required. Links each rendered element to its corresponding product card.

Deprecated Slot Aliases

Some slot names have been renamed for consistency. The old names still work — the SDK automatically redirects them to the new name at runtime — but they are deprecated and may be removed in a future major version.

danger

We recommend updating your code to use the new slot names as soon as possible. The deprecated aliases will continue to work for now, but they may stop working in a future release.

Deprecated nameUse instead
before_price_pdpbefore_product_detail_price
after_price_pdpafter_product_detail_price
before_add_to_cart_pdpbefore_product_detail_add_to_cart
after_add_to_cart_pdpafter_product_detail_add_to_cart
cart_line_item_topbefore_line_item
before_start_checkout_buttonbefore_go_to_checkout

If your app uses both the deprecated name and the new name for the same slot, the new name takes precedence and the deprecated entry is ignored.

Best Practices

  • Always use the product's ID as the key prop when rendering in product grid slots
  • Test your components with the Patagonia theme to ensure compatibility
  • Consider the visual impact of your components on the storefront design
  • Use responsive design principles for components that appear on different screen sizes
  • Clear slots when they're no longer needed using nube.clearSlot()

Help us improve NubeSDK

Found an issue or have a suggestion? Let us know on GitHub.