Preload checkout
Preloading fetches checkout in the background. When the buyer taps Checkout, checkout is already loaded and opens with no delay.
Anchor to RequirementsRequirements
- Checkout Kit installed in your app.
- A valid
checkoutUrlfrom Build a mobile storefront or a cart permalink.
Anchor to Enable preloadingEnable preloading
When the buyer navigates to the cart, call preload() to start fetching checkout in the background. By the time they tap Checkout, the page is ready:
Preload checkout
Swift
ShopifyCheckoutSheetKit.preload(checkout: checkoutURL)Kotlin
ShopifyCheckoutSheetKit.preload(checkoutUrl, context)React Native
// using hooks
const shopifyCheckout = useShopifyCheckoutSheet();
shopifyCheckout.preload(checkoutUrl);
// using a class instance
const shopifyCheckout = new ShopifyCheckoutSheet();
shopifyCheckout.preload(checkoutUrl);Avoid calling preload() on every add-to-cart action. Frequent preloading triggers background network requests, increases memory usage, and might trigger Storefront API rate limits.
Avoid calling preload() on every add-to-cart action. Frequent preloading triggers background network requests, increases memory usage, and might trigger Storefront API rate limits.
Anchor to Manage preloaded checkoutsManage preloaded checkouts
Preloading renders checkout in a background WebView. The preloaded checkout reflects the cart at the time you call preload(). When you call ShopifyCheckoutSheetKit.present(), the checkout moves to the foreground.
If the cart changes after preloading, call preload() again to refresh, or call ShopifyCheckoutSheetKit.invalidate() to clear the cache. Closing checkout doesn't automatically invalidate preloaded content, so update it when the buyer modifies their cart.
Checkout Kit might delay or skip preloading during high traffic. If preloading doesn't complete before you call present(checkoutUrl), then buyers see a loading state.
Anchor to Disable preloadingDisable preloading
To disable preloading, set enabled to false. You might disable it when a buyer enables data saver mode. When disabled, Checkout Kit ignores all calls to preload():
Disable preloading
Swift
ShopifyCheckoutSheetKit.configure {
$0.preloading.enabled = false // defaults to true
}Kotlin
ShopifyCheckoutSheetKit.configure {
it.preloading = Preloading(enabled = false) // defaults to true
}React Native
import { ShopifyCheckoutSheetProvider } from '@shopify/checkout-sheet-kit';
const configuration = { preloading: false };
<ShopifyCheckoutSheetProvider configuration={configuration}>
<App />
</ShopifyCheckoutSheetProvider>