learnshopify.dev/Workspace
code reading

Read the Roast Club profile block. Trace how it gets its data.

import '@shopify/ui-extensions/preact';
import {render} from 'preact';
import {useState, useEffect} from 'preact/hooks';

export default function extension() {
  render(<RoastClubCard />, document.body);
}

function RoastClubCard() {
  const [customer, setCustomer] = useState(null);

  useEffect(() => {
    fetch('shopify://customer-account/api/2026-04/graphql.json', {
      method: 'POST',
      headers: {'Content-Type': 'application/json'},
      body: JSON.stringify({
        query: `query { customer { firstName } }`,
      }),
    })
      .then((response) => response.json())
      .then(({data}) => setCustomer(data.customer))
      .catch(console.error);
  }, []);

  if (!customer) {
    return <s-spinner accessibilityLabel="Loading your Roast Club status" />;
  }

  return (
    <s-section heading="Roast Club">
      <s-stack gap="base">
        <s-text>
          {customer.firstName}, you're a Roast Club member. Every order
          ships within 48 hours of roasting.
        </s-text>
        <s-text color="subdued">
          Member perks: early access to micro-lots and free shipping over $40.
        </s-text>
      </s-stack>
    </s-section>
  );
}
1. Why can't this card ship as a theme section?
2. How is the GraphQL request authenticated?
3. What does a member see while the request is in flight?
4. Who decides where this block sits on the profile page?
0 / 1 task solved