<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gowtham Eswaramoorthy on Medium]]></title>
        <description><![CDATA[Stories by Gowtham Eswaramoorthy on Medium]]></description>
        <link>https://medium.com/@gowthameswaramoorthy?source=rss-a6dd100f4ea6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wh-zbFQun0iC37DV.jpg</url>
            <title>Stories by Gowtham Eswaramoorthy on Medium</title>
            <link>https://medium.com/@gowthameswaramoorthy?source=rss-a6dd100f4ea6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:40:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gowthameswaramoorthy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Production-Ready Sitecore Marketplace Apps with Next.js]]></title>
            <link>https://medium.com/@gowthameswaramoorthy/building-production-ready-sitecore-marketplace-apps-with-next-js-c81985f878c2?source=rss-a6dd100f4ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c81985f878c2</guid>
            <category><![CDATA[sitecore]]></category>
            <category><![CDATA[sitecore-ai]]></category>
            <category><![CDATA[sitecore-marketplace-sdk]]></category>
            <category><![CDATA[marketplace-sdk]]></category>
            <category><![CDATA[sitecore-marketplace]]></category>
            <dc:creator><![CDATA[Gowtham Eswaramoorthy]]></dc:creator>
            <pubDate>Mon, 23 Feb 2026 04:30:30 GMT</pubDate>
            <atom:updated>2026-03-07T01:07:13.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Building production Sitecore Marketplace apps with extension points and XM Cloud API integration" src="https://cdn-images-1.medium.com/max/1024/1*8gaHOaOIAJaW3tQkRTHNAw.png" /></figure><p>In <a href="https://www.gowthamaraja.com/sitecore-marketplace-getting-started-nextjs">Part 1</a>, we built our first Marketplace app and got it running in XM Cloud. Now it’s time to take things to the next level — building production-ready apps that actually solve real problems.</p><p>We’ll explore all four extension types, integrate with XM Cloud APIs, and write code that you can confidently deploy to production.</p><h3>Table of Contents</h3><ol><li><a href="#ce54">Recap: Where We Left Off</a></li><li><a href="#f20e">Understanding Extension Points in Depth</a></li><li><a href="#036f">Building a Standalone Application</a></li><li><a href="#5765">Creating Dashboard Widgets</a></li><li><a href="#0790">Building Custom Field Extensions</a></li><li><a href="#a87e">Working with XM Cloud APIs</a></li><li><a href="#2c2f">Fetching Real Content Data</a></li><li><a href="#f80c">Handling API Errors Gracefully</a></li><li><a href="#8cc5">State Management Best Practices</a></li><li><a href="#af48">What’s Next?</a></li></ol><h3>Recap: Where We Left Off</h3><p>In Part 1, we created a basic analytics dashboard that:</p><ul><li>Initialized the Marketplace SDK</li><li>Fetched application context</li><li>Displayed mock statistics</li><li>Ran successfully in XM Cloud Portal</li></ul><p>Now we’ll enhance this foundation with real functionality and explore other extension types.</p><h3>Understanding Extension Points in Depth</h3><p>Sitecore Marketplace offers four extension points. Each serves different use cases and user workflows.</p><figure><img alt="Sitecore Extension Points" src="https://cdn-images-1.medium.com/max/1024/1*LT35fUDEaNbZ1fb2qv6JhQ.png" /><figcaption>Sitecore Extension Points</figcaption></figure><h3>1. Standalone Application</h3><p><strong>Best For:</strong></p><ul><li>Admin dashboards and reporting tools</li><li>Bulk content operations</li><li>Configuration interfaces</li><li>Complex workflows that need dedicated space</li></ul><p><strong>User Access:</strong> Via “My Apps” in the main navigation</p><p><strong>Screen Real Estate:</strong> Full page within the portal</p><h3>2. Full-Screen Experience</h3><p><strong>Best For:</strong></p><ul><li>Content migration tools</li><li>Immersive workflows</li><li>Multi-step wizards</li><li>Tasks requiring maximum focus</li></ul><p><strong>User Access:</strong> Takes over the entire portal interface</p><p><strong>Screen Real Estate:</strong> Complete viewport</p><h3>3. Dashboard Widgets</h3><p><strong>Best For:</strong></p><ul><li>At-a-glance metrics</li><li>Quick status indicators</li><li>Action buttons for common tasks</li><li>Real-time notifications</li></ul><p><strong>User Access:</strong> Site dashboard cards</p><p><strong>Screen Real Estate:</strong> Compact cards (typically 300–400px wide)</p><h3>4. Page Builder Extensions</h3><p><strong>Custom Fields:</strong></p><ul><li>New field types (color pickers, icon selectors, etc.)</li><li>Enhanced input controls</li><li>Validation and formatting</li></ul><p><strong>Context Panels:</strong></p><ul><li>Content suggestions</li><li>SEO analysis</li><li>AI-powered recommendations</li><li>Workflow helpers</li></ul><p><strong>User Access:</strong> Content editor sidebar or field locations</p><p><strong>Screen Real Estate:</strong> Varies by type</p><h3>Building a Standalone Application</h3><p>Let’s enhance our analytics dashboard from Part 1 with real functionality.</p><h3>Advanced Features</h3><p>We’ll add:</p><ul><li>Real-time data updates</li><li>Multiple chart types</li><li>Date range filtering</li><li>Export functionality</li></ul><h3>Enhanced Dashboard Component</h3><p>Update src/app/standalone/page.tsx:</p><pre>&quot;use client&quot;;<br><br>import { useMarketplaceClient } from &quot;@/hooks/useMarketplaceClient&quot;;<br>import { ApplicationContext } from &quot;@sitecore-marketplace-sdk/client&quot;;<br>import { useEffect, useState } from &quot;react&quot;;<br>import { initializeXMC } from &quot;@/lib/xmcClient&quot;;<br>interface ContentStats {<br>  totalItems: number;<br>  publishedToday: number;<br>  draftItems: number;<br>  scheduledPublishing: number;<br>  lastUpdated: Date;<br>}<br>interface ActivityItem {<br>  id: string;<br>  action: string;<br>  user: string;<br>  timestamp: Date;<br>}<br>export default function AnalyticsDashboard() {<br>  const { client, error, isInitialized, isLoading } = useMarketplaceClient();<br>  const [appContext, setAppContext] = useState&lt;ApplicationContext | null&gt;(null);<br>  const [stats, setStats] = useState&lt;ContentStats | null&gt;(null);<br>  const [activity, setActivity] = useState&lt;ActivityItem[]&gt;([]);<br>  const [refreshing, setRefreshing] = useState(false);<br>  // Fetch application context<br>  useEffect(() =&gt; {<br>    if (!isInitialized || !client) return;<br>    async function fetchContext() {<br>      try {<br>        const response = await client.query(&quot;application.context&quot;);<br>        setAppContext(response.data);<br>      } catch (err) {<br>        console.error(&quot;Failed to fetch context:&quot;, err);<br>      }<br>    }<br>    fetchContext();<br>  }, [client, isInitialized]);<br>  // Fetch content statistics<br>  useEffect(() =&gt; {<br>    if (!appContext || !client) return;<br>    fetchStats();<br>    // Auto-refresh every 30 seconds<br>    const interval = setInterval(fetchStats, 30000);<br>    return () =&gt; clearInterval(interval);<br>  }, [appContext, client]);<br>  async function fetchStats() {<br>    if (!client) return;<br>    <br>    setRefreshing(true);<br>    <br>    try {<br>      const xmc = await initializeXMC(client);<br>      // GraphQL query for content statistics<br>      const query = `<br>        query GetContentStats {<br>          search(<br>            where: {<br>              AND: [<br>                { name: &quot;_path&quot;, value: &quot;/sitecore/content/&quot;, operator: CONTAINS }<br>              ]<br>            }<br>            first: 1000<br>          ) {<br>            total<br>            results {<br>              id<br>              name<br>              updated<br>              published: field(name: &quot;__Published&quot;) {<br>                value<br>              }<br>            }<br>          }<br>        }<br>      `;<br>      const response = await xmc.graphQL.query({ query });<br>      const items = response.data.search.results;<br>      <br>      // Calculate statistics<br>      const today = new Date();<br>      today.setHours(0, 0, 0, 0);<br>      const publishedToday = items.filter((item: any) =&gt; {<br>        const updateDate = new Date(item.updated);<br>        return updateDate &gt;= today;<br>      }).length;<br>      setStats({<br>        totalItems: response.data.search.total,<br>        publishedToday,<br>        draftItems: items.filter((i: any) =&gt; !i.published?.value).length,<br>        scheduledPublishing: 0, // Would need workflow API<br>        lastUpdated: new Date(),<br>      });<br>      // Fetch recent activity<br>      const recentItems = items<br>        .slice(0, 5)<br>        .map((item: any) =&gt; ({<br>          id: item.id,<br>          action: &quot;Updated&quot;,<br>          user: &quot;Content Editor&quot;,<br>          timestamp: new Date(item.updated),<br>        }));<br>      setActivity(recentItems);<br>    } catch (err) {<br>      console.error(&quot;Failed to fetch stats:&quot;, err);<br>      // Fallback to mock data<br>      setStats({<br>        totalItems: 1247,<br>        publishedToday: 23,<br>        draftItems: 156,<br>        scheduledPublishing: 8,<br>        lastUpdated: new Date(),<br>      });<br>    } finally {<br>      setRefreshing(false);<br>    }<br>  }<br>  if (isLoading) {<br>    return &lt;LoadingScreen /&gt;;<br>  }<br>  if (error) {<br>    return &lt;ErrorScreen error={error} /&gt;;<br>  }<br>  return (<br>    &lt;div className=&quot;min-h-screen bg-gray-50 p-6&quot;&gt;<br>      &lt;div className=&quot;max-w-7xl mx-auto&quot;&gt;<br>        {/* Header with refresh */}<br>        &lt;div className=&quot;flex items-center justify-between mb-8&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h1 className=&quot;text-3xl font-bold text-gray-900&quot;&gt;<br>              Content Analytics<br>            &lt;/h1&gt;<br>            &lt;p className=&quot;text-gray-600 mt-1&quot;&gt;<br>              {appContext?.organization?.name || &quot;Your Organization&quot;}<br>            &lt;/p&gt;<br>          &lt;/div&gt;<br>          <br>          &lt;button<br>            onClick={fetchStats}<br>            disabled={refreshing}<br>            className=&quot;flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50&quot;<br>          &gt;<br>            &lt;RefreshIcon className={refreshing ? &quot;animate-spin&quot; : &quot;&quot;} /&gt;<br>            Refresh<br>          &lt;/button&gt;<br>        &lt;/div&gt;<br>        {/* Stats Grid */}<br>        {stats &amp;&amp; (<br>          &lt;&gt;<br>            &lt;div className=&quot;grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8&quot;&gt;<br>              &lt;StatCard<br>                title=&quot;Total Items&quot;<br>                value={stats.totalItems.toLocaleString()}<br>                icon=&quot;📊&quot;<br>                trend=&quot;+12%&quot;<br>                trendUp={true}<br>              /&gt;<br>              &lt;StatCard<br>                title=&quot;Published Today&quot;<br>                value={stats.publishedToday.toString()}<br>                icon=&quot;✅&quot;<br>                trend=&quot;+5&quot;<br>                trendUp={true}<br>              /&gt;<br>              &lt;StatCard<br>                title=&quot;Draft Items&quot;<br>                value={stats.draftItems.toString()}<br>                icon=&quot;📝&quot;<br>                trend=&quot;-3&quot;<br>                trendUp={false}<br>              /&gt;<br>              &lt;StatCard<br>                title=&quot;Scheduled&quot;<br>                value={stats.scheduledPublishing.toString()}<br>                icon=&quot;⏰&quot;<br>                trend=&quot;→&quot;<br>                trendUp={null}<br>              /&gt;<br>            &lt;/div&gt;<br>            &lt;p className=&quot;text-sm text-gray-500 mb-8&quot;&gt;<br>              Last updated: {stats.lastUpdated.toLocaleTimeString()}<br>            &lt;/p&gt;<br>          &lt;/&gt;<br>        )}<br>        {/* Recent Activity */}<br>        &lt;div className=&quot;bg-white rounded-lg shadow&quot;&gt;<br>          &lt;div className=&quot;px-6 py-4 border-b border-gray-200&quot;&gt;<br>            &lt;h2 className=&quot;text-xl font-semibold text-gray-900&quot;&gt;<br>              Recent Activity<br>            &lt;/h2&gt;<br>          &lt;/div&gt;<br>          &lt;div className=&quot;divide-y divide-gray-200&quot;&gt;<br>            {activity.map((item) =&gt; (<br>              &lt;div key={item.id} className=&quot;px-6 py-4 flex items-center justify-between&quot;&gt;<br>                &lt;div&gt;<br>                  &lt;p className=&quot;font-medium text-gray-900&quot;&gt;{item.action}&lt;/p&gt;<br>                  &lt;p className=&quot;text-sm text-gray-500&quot;&gt;by {item.user}&lt;/p&gt;<br>                &lt;/div&gt;<br>                &lt;p className=&quot;text-sm text-gray-500&quot;&gt;<br>                  {formatTimeAgo(item.timestamp)}<br>                &lt;/p&gt;<br>              &lt;/div&gt;<br>            ))}<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>// Helper components<br>function StatCard({ title, value, icon, trend, trendUp }: any) {<br>  const trendColor = trendUp === true ? &quot;text-green-600&quot; : <br>                     trendUp === false ? &quot;text-red-600&quot; : &quot;text-gray-600&quot;;<br>  return (<br>    &lt;div className=&quot;bg-white rounded-lg shadow p-6&quot;&gt;<br>      &lt;div className=&quot;flex items-center justify-between mb-4&quot;&gt;<br>        &lt;span className=&quot;text-3xl&quot;&gt;{icon}&lt;/span&gt;<br>        &lt;span className={`text-sm font-medium ${trendColor}`}&gt;<br>          {trend}<br>        &lt;/span&gt;<br>      &lt;/div&gt;<br>      &lt;h3 className=&quot;text-gray-500 text-sm font-medium mb-2&quot;&gt;{title}&lt;/h3&gt;<br>      &lt;p className=&quot;text-3xl font-bold text-gray-900&quot;&gt;{value}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>function RefreshIcon({ className }: { className?: string }) {<br>  return (<br>    &lt;svg className={`w-5 h-5 ${className}`} fill=&quot;none&quot; viewBox=&quot;0 0 24 24&quot; stroke=&quot;currentColor&quot;&gt;<br>      &lt;path strokeLinecap=&quot;round&quot; strokeLinejoin=&quot;round&quot; strokeWidth={2} d=&quot;M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15&quot; /&gt;<br>    &lt;/svg&gt;<br>  );<br>}<br>function formatTimeAgo(date: Date): string {<br>  const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000);<br>  <br>  if (seconds &lt; 60) return &quot;just now&quot;;<br>  if (seconds &lt; 3600) return `${Math.floor(seconds / 60)}m ago`;<br>  if (seconds &lt; 86400) return `${Math.floor(seconds / 3600)}h ago`;<br>  return `${Math.floor(seconds / 86400)}d ago`;<br>}<br>function LoadingScreen() {<br>  return (<br>    &lt;div className=&quot;flex items-center justify-center min-h-screen bg-gray-50&quot;&gt;<br>      &lt;div className=&quot;text-center&quot;&gt;<br>        &lt;div className=&quot;animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto&quot;&gt;&lt;/div&gt;<br>        &lt;p className=&quot;mt-4 text-gray-600&quot;&gt;Loading dashboard...&lt;/p&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>function ErrorScreen({ error }: { error: Error }) {<br>  return (<br>    &lt;div className=&quot;flex items-center justify-center min-h-screen bg-gray-50&quot;&gt;<br>      &lt;div className=&quot;bg-red-50 border border-red-200 rounded-lg p-6 max-w-md&quot;&gt;<br>        &lt;h2 className=&quot;text-red-800 font-semibold text-lg mb-2&quot;&gt;<br>          ⚠️ Error Loading Dashboard<br>        &lt;/h2&gt;<br>        &lt;p className=&quot;text-red-600 text-sm&quot;&gt;{error.message}&lt;/p&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Creating Dashboard Widgets</h3><p>Dashboard widgets are compact, focused components perfect for at-a-glance information.</p><h3>Widget Design Principles</h3><ol><li><strong>Keep it focused</strong>: One primary metric or action</li><li><strong>Make it actionable</strong>: Include a CTA button</li><li><strong>Update in real-time</strong>: Show live data when possible</li><li><strong>Be responsive</strong>: Work on different screen sizes</li></ol><h3>Building a Content Approval Widget</h3><p>Create src/app/dashboard-widget/page.tsx:</p><pre>&quot;use client&quot;;<br>import { useMarketplaceClient } from &quot;@/hooks/useMarketplaceClient&quot;;<br>import { useEffect, useState } from &quot;react&quot;;<br>interface ApprovalStats {<br>  pending: number;<br>  approved: number;<br>  rejected: number;<br>}<br>export default function ApprovalWidget() {<br>  const { client, isInitialized } = useMarketplaceClient();<br>  const [stats, setStats] = useState&lt;ApprovalStats&gt;({<br>    pending: 0,<br>    approved: 0,<br>    rejected: 0,<br>  });<br>  useEffect(() =&gt; {<br>    if (!isInitialized || !client) return;<br>    async function fetchApprovals() {<br>      // In production, fetch from workflow API<br>      setStats({<br>        pending: 8,<br>        approved: 45,<br>        rejected: 2,<br>      });<br>    }<br>    fetchApprovals();<br>    <br>    // Refresh every minute<br>    const interval = setInterval(fetchApprovals, 60000);<br>    return () =&gt; clearInterval(interval);<br>  }, [client, isInitialized]);<br>  return (<br>    &lt;div className=&quot;p-4 bg-white rounded-lg h-full&quot;&gt;<br>      &lt;div className=&quot;flex items-center justify-between mb-4&quot;&gt;<br>        &lt;h3 className=&quot;text-lg font-semibold text-gray-900&quot;&gt;<br>          Content Approvals<br>        &lt;/h3&gt;<br>        &lt;span className=&quot;text-2xl&quot;&gt;📋&lt;/span&gt;<br>      &lt;/div&gt;<br>      <br>      &lt;div className=&quot;space-y-3&quot;&gt;<br>        &lt;ApprovalRow<br>          label=&quot;Pending Review&quot;<br>          count={stats.pending}<br>          color=&quot;orange&quot;<br>          pulse={stats.pending &gt; 0}<br>        /&gt;<br>        &lt;ApprovalRow<br>          label=&quot;Approved Today&quot;<br>          count={stats.approved}<br>          color=&quot;green&quot;<br>        /&gt;<br>        &lt;ApprovalRow<br>          label=&quot;Rejected&quot;<br>          count={stats.rejected}<br>          color=&quot;red&quot;<br>        /&gt;<br>      &lt;/div&gt;<br>      <br>      &lt;button className=&quot;mt-4 w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition-colors text-sm font-medium&quot;&gt;<br>        View All Workflows<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>function ApprovalRow({ label, count, color, pulse }: any) {<br>  const colors = {<br>    orange: &quot;bg-orange-100 text-orange-700&quot;,<br>    green: &quot;bg-green-100 text-green-700&quot;,<br>    red: &quot;bg-red-100 text-red-700&quot;,<br>  };<br>  return (<br>    &lt;div className=&quot;flex items-center justify-between py-2&quot;&gt;<br>      &lt;span className=&quot;text-sm text-gray-600&quot;&gt;{label}&lt;/span&gt;<br>      &lt;span className={`<br>        px-3 py-1 rounded-full text-sm font-semibold<br>        ${colors[color]}<br>        ${pulse ? &#39;animate-pulse&#39; : &#39;&#39;}<br>      `}&gt;<br>        {count}<br>      &lt;/span&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>Register this widget:</strong></p><ul><li>Extension point: Dashboard widgets</li><li>Deployment URL: <a href="http://localhost:3000/dashboard-widget">http://localhost:3000/dashboard-widget</a></li></ul><h3>Building Custom Field Extensions</h3><p>Custom fields let you add new input types to the content editor.</p><h3>Building a Color Picker Field</h3><p>Create src/app/custom-field/page.tsx:</p><pre>&quot;use client&quot;;<br>import { useMarketplaceClient } from &quot;@/hooks/useMarketplaceClient&quot;;<br>import { useEffect, useState } from &quot;react&quot;;<br>const PRESET_COLORS = [<br>  { name: &quot;Primary Blue&quot;, value: &quot;#3B82F6&quot; },<br>  { name: &quot;Success Green&quot;, value: &quot;#10B981&quot; },<br>  { name: &quot;Warning Orange&quot;, value: &quot;#F59E0B&quot; },<br>  { name: &quot;Danger Red&quot;, value: &quot;#EF4444&quot; },<br>  { name: &quot;Purple&quot;, value: &quot;#8B5CF6&quot; },<br>  { name: &quot;Pink&quot;, value: &quot;#EC4899&quot; },<br>  { name: &quot;Teal&quot;, value: &quot;#14B8A6&quot; },<br>  { name: &quot;Gray&quot;, value: &quot;#6B7280&quot; },<br>];<br>export default function ColorPickerField() {<br>  const { client, isInitialized } = useMarketplaceClient();<br>  const [selectedColor, setSelectedColor] = useState(&quot;#3B82F6&quot;);<br>  const [customColor, setCustomColor] = useState(&quot;#3B82F6&quot;);<br>  useEffect(() =&gt; {<br>    if (!isInitialized || !client) return;<br>    async function initField() {<br>      try {<br>        // Get current field value<br>        const context = await client.query(&quot;field.context&quot;);<br>        if (context.data?.value) {<br>          setSelectedColor(context.data.value);<br>          setCustomColor(context.data.value);<br>        }<br>      } catch (err) {<br>        console.error(&quot;Failed to get field context:&quot;, err);<br>      }<br>    }<br>    initField();<br>  }, [client, isInitialized]);<br>  const updateColor = async (color: string) =&gt; {<br>    setSelectedColor(color);<br>    setCustomColor(color);<br>    if (!client) return;<br>    try {<br>      // Update field value in Sitecore<br>      await client.query(&quot;field.setValue&quot;, { value: color });<br>    } catch (err) {<br>      console.error(&quot;Failed to update field:&quot;, err);<br>    }<br>  };<br>  return (<br>    &lt;div className=&quot;p-4 max-w-md&quot;&gt;<br>      {/* Color Preview */}<br>      &lt;div className=&quot;mb-6&quot;&gt;<br>        &lt;div<br>          className=&quot;w-full h-24 rounded-lg border-2 border-gray-200 shadow-sm&quot;<br>          style={{ backgroundColor: selectedColor }}<br>        /&gt;<br>        &lt;p className=&quot;text-center mt-3 text-lg font-mono font-semibold text-gray-700&quot;&gt;<br>          {selectedColor}<br>        &lt;/p&gt;<br>      &lt;/div&gt;<br>      {/* Preset Colors */}<br>      &lt;div className=&quot;mb-6&quot;&gt;<br>        &lt;label className=&quot;block text-sm font-medium text-gray-700 mb-3&quot;&gt;<br>          Preset Colors<br>        &lt;/label&gt;<br>        &lt;div className=&quot;grid grid-cols-4 gap-3&quot;&gt;<br>          {PRESET_COLORS.map((color) =&gt; (<br>            &lt;button<br>              key={color.value}<br>              onClick={() =&gt; updateColor(color.value)}<br>              className={`<br>                h-12 rounded-lg transition-all<br>                ${selectedColor === color.value <br>                  ? &#39;ring-2 ring-blue-500 ring-offset-2 scale-110&#39; <br>                  : &#39;hover:scale-105&#39;}<br>              `}<br>              style={{ backgroundColor: color.value }}<br>              title={color.name}<br>            /&gt;<br>          ))}<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      {/* Custom Color Input */}<br>      &lt;div&gt;<br>        &lt;label className=&quot;block text-sm font-medium text-gray-700 mb-2&quot;&gt;<br>          Custom Color<br>        &lt;/label&gt;<br>        &lt;div className=&quot;flex gap-3&quot;&gt;<br>          &lt;input<br>            type=&quot;color&quot;<br>            value={customColor}<br>            onChange={(e) =&gt; setCustomColor(e.target.value)}<br>            className=&quot;h-12 w-20 rounded-lg cursor-pointer&quot;<br>          /&gt;<br>          &lt;button<br>            onClick={() =&gt; updateColor(customColor)}<br>            className=&quot;flex-1 bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 font-medium&quot;<br>          &gt;<br>            Apply Custom Color<br>          &lt;/button&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>To use this field:</strong></p><ol><li>Enable “Custom Field” extension point</li><li>In Sitecore, add field to content template</li><li>Set field type to “Marketplace Type → Plugin”</li><li>Select your app from dropdown</li></ol><h3>Working with XM Cloud APIs</h3><p>The XMC package gives you access to powerful content operations.</p><h3>Initializing the XMC Client</h3><p>Create src/lib/xmcClient.ts:</p><pre>import { XMC } from &quot;@sitecore-marketplace-sdk/xmc&quot;;<br>import { ClientSDK } from &quot;@sitecore-marketplace-sdk/client&quot;;<br><br>let xmcInstance: XMC | null = null;<br>export async function initializeXMC(marketplaceClient: ClientSDK): Promise&lt;XMC&gt; {<br>  if (xmcInstance) return xmcInstance;<br>  xmcInstance = new XMC({ client: marketplaceClient });<br>  await xmcInstance.init();<br>  <br>  console.log(&quot;✅ XM Cloud API client initialized&quot;);<br>  return xmcInstance;<br>}<br>export function getXMC(): XMC {<br>  if (!xmcInstance) {<br>    throw new Error(&quot;XMC not initialized&quot;);<br>  }<br>  return xmcInstance;<br>}g</pre><h3>Common API Operations</h3><pre>// Fetch content items<br>const query = `<br>  query GetItems {<br>    item(path: &quot;/sitecore/content/home&quot;) {<br>      id<br>      name<br>      children {<br>        results {<br>          id<br>          name<br>          path<br>        }<br>      }<br>    }<br>  }<br>`;<br><br>const response = await xmc.graphQL.query({ query });<br>// Create a new item<br>const createMutation = `<br>  mutation CreateItem($input: CreateItemInput!) {<br>    createItem(input: $input) {<br>      id<br>      name<br>    }<br>  }<br>`;<br>await xmc.graphQL.query({<br>  query: createMutation,<br>  variables: {<br>    input: {<br>      name: &quot;New Page&quot;,<br>      templateId: &quot;template-id-here&quot;,<br>      parent: &quot;parent-item-id&quot;<br>    }<br>  }<br>});</pre><h3>Fetching Real Content Data</h3><p>Let’s implement a practical content browser component.</p><pre>interface ContentItem {<br>  id: string;<br>  name: string;<br>  path: string;<br>  template: string;<br>  hasChildren: boolean;<br>}<br><br>export function ContentBrowser() {<br>  const { client } = useMarketplaceClient();<br>  const [items, setItems] = useState&lt;ContentItem[]&gt;([]);<br>  const [loading, setLoading] = useState(false);<br>  const [currentPath, setCurrentPath] = useState(&quot;/sitecore/content&quot;);<br>  async function loadItems(path: string) {<br>    if (!client) return;<br>    <br>    setLoading(true);<br>    <br>    try {<br>      const xmc = await initializeXMC(client);<br>      <br>      const query = `<br>        query GetChildren($path: String!) {<br>          item(path: $path) {<br>            id<br>            name<br>            children {<br>              results {<br>                id<br>                name<br>                path<br>                template {<br>                  name<br>                }<br>                hasChildren<br>              }<br>            }<br>          }<br>        }<br>      `;<br>      const response = await xmc.graphQL.query({<br>        query,<br>        variables: { path }<br>      });<br>      setItems(response.data.item.children.results);<br>      setCurrentPath(path);<br>    } catch (err) {<br>      console.error(&quot;Failed to load items:&quot;, err);<br>    } finally {<br>      setLoading(false);<br>    }<br>  }<br>  return (<br>    &lt;div className=&quot;p-6&quot;&gt;<br>      &lt;div className=&quot;mb-4&quot;&gt;<br>        &lt;p className=&quot;text-sm text-gray-600&quot;&gt;Current: {currentPath}&lt;/p&gt;<br>      &lt;/div&gt;<br>      <br>      {loading ? (<br>        &lt;div className=&quot;text-center py-8&quot;&gt;Loading...&lt;/div&gt;<br>      ) : (<br>        &lt;div className=&quot;space-y-2&quot;&gt;<br>          {items.map((item) =&gt; (<br>            &lt;div<br>              key={item.id}<br>              onClick={() =&gt; item.hasChildren &amp;&amp; loadItems(item.path)}<br>              className=&quot;p-3 bg-white rounded border hover:bg-gray-50 cursor-pointer&quot;<br>            &gt;<br>              &lt;p className=&quot;font-medium&quot;&gt;{item.name}&lt;/p&gt;<br>              &lt;p className=&quot;text-sm text-gray-500&quot;&gt;{item.template}&lt;/p&gt;<br>            &lt;/div&gt;<br>          ))}<br>        &lt;/div&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Handling API Errors Gracefully</h3><p>Production apps need robust error handling.</p><h3>Error Boundary Component</h3><pre>import { Component, ReactNode } from &#39;react&#39;;<br><br>interface Props {<br>  children: ReactNode;<br>}<br>interface State {<br>  hasError: boolean;<br>  error: Error | null;<br>}<br>export class ErrorBoundary extends Component&lt;Props, State&gt; {<br>  constructor(props: Props) {<br>    super(props);<br>    this.state = { hasError: false, error: null };<br>  }<br>  static getDerivedStateFromError(error: Error) {<br>    return { hasError: true, error };<br>  }<br>  render() {<br>    if (this.state.hasError) {<br>      return (<br>        &lt;div className=&quot;p-6 bg-red-50 border border-red-200 rounded-lg&quot;&gt;<br>          &lt;h2 className=&quot;text-lg font-semibold text-red-800 mb-2&quot;&gt;<br>            Something went wrong<br>          &lt;/h2&gt;<br>          &lt;p className=&quot;text-red-600 text-sm&quot;&gt;<br>            {this.state.error?.message}<br>          &lt;/p&gt;<br>          &lt;button<br>            onClick={() =&gt; this.setState({ hasError: false, error: null })}<br>            className=&quot;mt-4 px-4 py-2 bg-red-600 text-white rounded&quot;<br>          &gt;<br>            Try Again<br>          &lt;/button&gt;<br>        &lt;/div&gt;<br>      );<br>    }<br>    return this.props.children;<br>  }<br>}t</pre><h3>API Error Handler</h3><pre>export async function handleAPICall&lt;T&gt;(<br>  apiCall: () =&gt; Promise&lt;T&gt;,<br>  fallbackValue?: T<br>): Promise&lt;T&gt; {<br>  try {<br>    return await apiCall();<br>  } catch (error) {<br>    console.error(&quot;API call failed:&quot;, error);<br>    <br>    if (fallbackValue !== undefined) {<br>      return fallbackValue;<br>    }<br>    <br>    throw error;<br>  }<br>}<br><br>// Usage<br>const data = await handleAPICall(<br>  () =&gt; xmc.graphQL.query({ query }),<br>  [] // fallback to empty array<br>);</pre><h3>State Management Best Practices</h3><p>For complex apps, consider using a state management library.</p><h3>Using React Context</h3><pre>import { createContext, useContext, useState, ReactNode } from &#39;react&#39;;<br><br>interface AppState {<br>  stats: ContentStats | null;<br>  setStats: (stats: ContentStats) =&gt; void;<br>  refreshData: () =&gt; Promise&lt;void&gt;;<br>}<br>const AppContext = createContext&lt;AppState | null&gt;(null);<br>export function AppProvider({ children }: { children: ReactNode }) {<br>  const [stats, setStats] = useState&lt;ContentStats | null&gt;(null);<br>  const refreshData = async () =&gt; {<br>    // Refresh logic here<br>  };<br>  return (<br>    &lt;AppContext.Provider value={{ stats, setStats, refreshData }}&gt;<br>      {children}<br>    &lt;/AppContext.Provider&gt;<br>  );<br>}<br>export function useAppState() {<br>  const context = useContext(AppContext);<br>  if (!context) throw new Error(&quot;useAppState must be used within AppProvider&quot;);<br>  return context;<br>}</pre><h3>What’s Next?</h3><p>You now have the skills to build production-ready Marketplace apps with:</p><ul><li>All four extension types</li><li>Real XM Cloud API integration</li><li>Proper error handling</li><li>State management</li></ul><p>In <strong>Part 3</strong>, we’ll cover:</p><ul><li>Deploying to production (Vercel, Netlify, Azure)</li><li>Performance optimization techniques</li><li>Security best practices</li><li>Monitoring and analytics</li><li>Publishing to public Marketplace</li></ul><h3>Quick Checklist</h3><p>Before deploying, make sure you have:</p><ul><li>Error boundaries in place</li><li>Loading states for all async operations</li><li>Fallback data for API failures</li><li>Responsive design tested</li><li>Console.log statements removed</li><li>TypeScript errors resolved</li></ul><p><strong>Next:</strong> <a href="https://www.gowthamaraja.com/sitecore-marketplace-production-apps-nextjs">Part 3 — Deploying and Optimizing Marketplace Apps →</a></p><p><em>Found this helpful? Follow for Part 3 where we deploy to production!</em></p><p><em>Have questions? Drop them in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c81985f878c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sitecore Order Cloud]]></title>
            <link>https://medium.com/@gowthameswaramoorthy/sitecore-order-cloud-5a13af5dbd5c?source=rss-a6dd100f4ea6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a13af5dbd5c</guid>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[sitecore]]></category>
            <category><![CDATA[headless-commerce]]></category>
            <category><![CDATA[ordercloud]]></category>
            <dc:creator><![CDATA[Gowtham Eswaramoorthy]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 12:09:46 GMT</pubDate>
            <atom:updated>2023-01-23T12:09:46.580Z</atom:updated>
            <content:encoded><![CDATA[<p>Sitecore OrderCloud is a powerful e-commerce platform that allows businesses to easily manage and optimize their online sales. With Sitecore OrderCloud, businesses can create a seamless shopping experience for their customers by integrating their e-commerce platform with their website and other digital channels.</p><p>One of the key features of Sitecore OrderCloud is its ability to personalize each customer’s shopping experience. Using Sitecore’s advanced analytics and machine learning capabilities, the platform can learn about each customer’s preferences and behaviour, and then use that information to recommend products and offers that are most likely to be of interest to them.</p><p>Another important aspect of Sitecore OrderCloud is its ability to handle large amounts of data and traffic. With its scalable architecture and robust infrastructure, the platform can easily handle high volumes of online orders and customer interactions, ensuring that businesses can meet the demands of their growing customer base.</p><p>In addition, Sitecore OrderCloud offers a wide range of tools and features for businesses to optimize their e-commerce operations. This includes tools for inventory management, order fulfilment, and customer service, as well as integrations with other platforms and systems such as CRM, marketing automation, and analytics.</p><h3>Why choose Sitecore OrderCloud?</h3><ol><li>Personalization: Sitecore OrderCloud’s ability to personalize each customer’s shopping experience can help businesses increase conversions and customer loyalty.</li><li>Scalability: Sitecore OrderCloud’s scalable architecture ensures that businesses can handle high volumes of online orders and customer interactions, allowing them to grow their customer base without worrying about the platform’s ability to handle the traffic.</li><li>Comprehensive E-commerce Features: Sitecore OrderCloud offers a wide range of tools and features for businesses to optimize their e-commerce operations, including inventory management, order fulfilment, and customer service.</li><li>Customer Service: Sitecore OrderCloud offers a range of customer service tools such as order tracking, returns management, and customer account management.</li><li>Order Fulfillment: Sitecore OrderCloud provides a range of tools and features for businesses to optimize their order fulfilment process, including automated order processing, shipping, and returns management.</li><li>Integrations: Sitecore OrderCloud easily integrates with other platforms and systems, such as CRM, marketing automation, and analytics, to provide a seamless end-to-end e-commerce experience.</li><li>Marketing Automation: Sitecore OrderCloud allows businesses to create and execute marketing campaigns, using the data captured by the platform to target specific segments of their customer base and optimize conversions.</li><li>Advanced Analytics: Sitecore OrderCloud provides businesses with detailed analytics on website traffic, conversion rates, and customer behaviour, allowing them to make data-driven decisions to improve their e-commerce operations.</li><li>Flexibility: Sitecore OrderCloud is highly flexible and customizable, allowing businesses to adapt it to their specific needs and requirements.</li><li>Marketing Automation: Sitecore OrderCloud provides businesses with the tools to execute targeted marketing campaigns, using the data captured by the platform to optimize conversions.</li><li>Support: Sitecore OrderCloud is supported by a dedicated team of professionals who can help businesses with the implementation, customization and maintenance of the platform.</li></ol><p>Overall, Sitecore OrderCloud is a comprehensive and highly flexible e-commerce platform that can help businesses of all sizes to grow their online sales and improve their customers’ shopping experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a13af5dbd5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>