Skip to content

Conversation

@jjolton-contentful
Copy link
Contributor

@jjolton-contentful jjolton-contentful commented Nov 21, 2025

Purpose

The useCMA hook is deprecated since App SDK v4.20 or greater.

This PR updates all the example apps to use the modern way of accessing the CMA - directly via sdk.cma.

Approach

Some implementations required a bit of manual adjustment (so in tending the garden a few unrelated bug fixes/type improvements are also included within this diff), but for the most part each change was identical and was performed via this script:

find . -type f \( -name "*.tsx" -o -name "*.jsx" \) -exec grep -l "useCMA" {} \; | while read file; do
  # Replace the import line - remove useCMA from the commented import
  sed -i '' 's|/\* useCMA, \*/ useSDK|useSDK|g' "$file"
  # Replace the usage line - change from useCMA() to sdk.cma
  sed -i '' 's|// const cma = useCMA();|// const cma = sdk.cma;|g' "$file"
  # Replace the comment text - change from "inject it as follows" to "access it as follows"
  sed -i '' 's|To use the cma, inject it as follows.|To use the cma, access it as follows.|g' "$file"
  echo "Updated: $file"
done

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes CMA (Content Management API) access across all example applications by replacing the deprecated useCMA hook with direct access via sdk.cma, aligning with App SDK v4.20+ best practices.

Key Changes:

  • Removed useCMA import from all example components
  • Updated CMA access pattern from const cma = useCMA() to const cma = sdk.cma
  • Revised documentation comments to reflect "access" rather than "inject" terminology

Reviewed changes

Copilot reviewed 62 out of 62 changed files in this pull request and generated no comments.

Show a summary per file
File Description
examples/vite-react/src/locations/*.tsx Updated all location components to use sdk.cma instead of useCMA hook
examples/typescript/src/locations/*.tsx Modernized CMA access pattern across all TypeScript example locations
examples/typescript-github-action/src/locations/*.tsx Applied sdk.cma pattern to GitHub Action example
examples/stateful-sidebar-with-dialog/src/locations/*.jsx Updated sidebar and dialog components to use modern CMA access
examples/page-location/src/locations/Page.tsx Replaced useCMA with sdk.cma and added PageAppSDK typing
examples/page-location/src/components/*.tsx Updated components to use sdk.cma and improved TypeScript types
examples/nextjs/components/locations/*.tsx Modernized CMA access in Next.js example components
examples/native-external-references-tmdb/src/locations/*.tsx Applied sdk.cma pattern to TMDB reference example
examples/javascript/src/locations/*.jsx Updated JavaScript examples to use modern CMA access
examples/home-location/src/locations/Home.tsx Replaced useCMA with sdk.cma and added HomeAppSDK typing
examples/home-location/src/components/*.tsx Updated Stats and Members components with proper SDK typing
examples/editor-assignment/src/locations/*.tsx Modernized CMA access across editor assignment example
examples/compare-entries/src/locations/*.tsx Updated Sidebar and Dialog to use sdk.cma
examples/blog-post-metrics/src/locations/*.tsx Applied modern CMA pattern to blog metrics example
examples/asset-upload/src/locations/Field.tsx Replaced useCMA with sdk.cma in asset upload field component

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@mgoudy91 mgoudy91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great update

@jjolton-contentful jjolton-contentful merged commit 13bab16 into master Nov 21, 2025
16 checks passed
@jjolton-contentful jjolton-contentful deleted the chore/modernize-cma-access-in-example-apps branch November 21, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants