Next.js Discord

Discord Forum

Configuring Categories Mega Menu API in Next.js v13.4.10 with Data Preloading

Unanswered
Longtail tuna posted this in #help-forum
Open in Discord
Longtail tunaOP
In my Next.js version 13.4.10 project, I am working on configuring a categories mega menu API. The goal is to preload this data either at build time or load it once during runtime. My _app.tsx structure involves using a Redux store provider, Google Analytics, and a custom layout component to wrap the pages. To pass the category API information, I have "feedItems" that consist of different category levels such as "Food & Beverages," "Snacks & Namkeen," and their respective subcategories like "Healthy Snacks," "Corn Based Chips," and more. The aim is to seamlessly integrate this data into my Next.js application to create a dynamic and user-friendly mega menu. I've pass this preloaded data to layout component. Since we can't use getstaticprops or getserversideprops and using getinitialprops disables automatic static optmiazation, i wanted to alternative ways for preload my api data.

_app.tsx structure
<Provider store={store}> <GoogleAnalytics measurementId={gtag.GA_TRACKING_ID} /> <Layout> <GoogleOAuthProvider clientId={process.env.NEXT_PUBLIC_GOOGLE_OAUTH_CLIENT_ID} > <Component {...pageProps} key={router.asPath} /> </GoogleOAuthProvider> </Layout> </Provider>

0 Replies