# gt-next: General Translation Next.js SDK: Cache Components URL: https://generaltranslation.com/en-GB/docs/next/guides/cache-components.mdx --- title: Cache Components description: Setting up Cache Components in gt-next --- This guide shows you how to use gt-next with Next.js Cache Components to optimise internationalised applications. *** ## Setup If you have not already, follow the [Next.js Cache Components guide](https://nextjs.org/docs/app/getting-started/cache-components) to set up cache components in your project. ### Enable cache components support in your gt-next configuration: ```js title="next.config.js" const nextConfig = { cacheComponents: true, }; export default withGTConfig(nextConfig, { experimentalLocaleResolution: true, }); ``` ### Enable middleware See the full middleware guide [here](/docs/next/guides/middleware). ```ts import { createNextMiddleware } from 'gt-next/middleware'; export default createNextMiddleware(); export const config = { // Match all paths except API routes, static files, and Next.js internals matcher: ['/((?!api|static|.*\\..*|_next).*)'] }; ``` ### Add the `locale` parameter to cached components with translatable content When using cached components with translatable content, you must pass `locale` as a parameter. This ensures each locale gets its own cache entry. ```tsx import { getLocale } from "gt-next/server" async function CachedContent({locale}: {locale: string}) { "use cache" return Hello World } export default async function Page() { const locale = await getLocale() return } ``` ## Configuration notes * Custom `getLocale` functions are overridden * `getRegion` and `getDomain` functions are disabled * You can customise the locale parameter name used for resolution with `experimentalLocaleResolutionParam` (default: `'locale'`) ```js title="next.config.js" export default withGTConfig(nextConfig, { experimentalLocaleResolution: true, experimentalLocaleResolutionParam: 'lang', // Optional customisation }); ``` *** ## Next steps * For more information, read the release notes for this feature: [gt-next@6.10.0](/devlog/gt-next_v6_10_0).