Nextjs recommends using the server-only package (simply imported into server components). This will cause a build-time error if it's inadvertently imported from a client component, making sure we're not accidentally accessing secrets from the browser/client components. Would it make sense to include this in the template?
To prevent this sort of unintended client usage of server code, we can use the server-only package to give other developers a build-time error if they ever accidentally import one of these modules into a Client Component.
Nextjs recommends using the
server-only
package (simply imported into server components). This will cause a build-time error if it's inadvertently imported from a client component, making sure we're not accidentally accessing secrets from the browser/client components. Would it make sense to include this in the template?https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#keeping-server-only-code-out-of-the-client-environment
To prevent this sort of unintended client usage of server code, we can use the server-only package to give other developers a build-time error if they ever accidentally import one of these modules into a Client Component.