Structuring and optimizing your TinaCMS project is essential to achieve clarity, enhance performance, and prevent build failures. Poorly optimized projects can lead to slow site performance, increased server load, and even failed builds due to excessive or inefficient data requests.
Let’s explore how to structure your project effectively and apply best practices to boost performance both in runtime and during the build process.
When working with large datasets or generating multiple subcomponents, following best practices is crucial to maintain performance and clarity.
export default async function Home({ params }: HomePageProps) {const location = params.location;const websiteProps = await client.queries.website({relativePath: `${location}/website.md`,});const { conferencesData, footerData, speakers } = websiteProps.data;return (<ConferenceContext.Provider value={conferencesData}><FooterContext.Provider value={footerData}><PageTransition><HomeComponent speakers={speakers} /></PageTransition></FooterContext.Provider></ConferenceContext.Provider>);}export async function generateStaticParams() {const contentDir = path.join(process.cwd(), 'content/websites');const locations = await fs.readdir(contentDir);return locations.map((location) => ({ location }));}
✅ Code: conferencesData and footerData are provided through context, while speakers are passed directly to HomeComponent as props.**
Optimizing runtime performance is key to delivering a fast and responsive user experience.
To ensure smooth and reliable builds, it’s important to follow best practices that prevent excessive server load and manage data efficiently.