Next.js Discord

Discord Forum

Turbo repo

Unanswered
shackicko posted this in #help-forum
Open in Discord
Avatar
shackickoOP
Hi, I need some help in figuring out a problem I've had for the past 1 and a half day. We are using Next JS in our company together with Turbo Repo, we've made several packages that are shared between multiple applications just like in the docs.

We're using Next JS 12.3.4 with latest React and React DOM versions.

Our problem is the following:
We're on our way to implement redis to cache some external data coming from a CMS and have created a separate package for the redis implementation(in case we will need to use it more in the future, not just for this use case) and then installed it as a dependency to another internal package that is responsible for communications between the Next JS app and the CMS.

This integration package has interfaces and logic for formatting the data to be used across several Next JS apps in this monorepo and some of the interfaces are referenced in components. This integration package has both logic that is meant to run only on the server(the formatting part) and the interfaces which are used on the client. Our problem is that the same code that is referenced only in the server side gets executed on the client as well which we don't want, because this breaks our whole application when integrating Redis.

How can we better separate this logic so that code meant from that package on the server gets executed only on the server and not on the client as well?

0 Replies