Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Can't use functions runnable on the server that are exported alongside client components #731

Open
roushou opened this issue Jun 27, 2024 · 3 comments

Comments

@roushou
Copy link
Contributor

roushou commented Jun 27, 2024

Describe the bug and the steps to reproduce it

This is related to an issue someone had on Discord https://discord.com/channels/1220414409550336183/1255514874860273708

Currently, module entrypoints export both functions runnable on the server and client components which makes Next.js not happy.

Here's a reproduction https://stackblitz.com/edit/stackblitz-starters-bmjcpd?file=app%2Fpage.tsx

Server components enable to do server-side actions directly inside React components, i.e.

export default async function MyPage() {
  const users = await db.users.select();
}

FWIW I'm not really fan of this but that's the direction things are heading.

So there are issues when trying to use things like getAttestations() in server components because @coinbase/onchainkit/identity also exports client components.

This should be fixable by separating exports to something like

  • @coinbase/onchainkit/<module>/core and @coinbase/onchainkit/<module>/react
  • @coinbase/onchainkit/<module>/core and @coinbase/onchainkit/<module> which exports components
  • @coinbase/onchainkit/core for all server side functions and @coinbase/onchainkit/<module> for client components

I find the 3rd option more intuitive as a consumer because of the clear distinction.

What's the expected behavior?

No response

What version of the libraries are you using?

0.23.2

@fakepixels
Copy link
Contributor

fakepixels commented Jun 27, 2024

This is great suggestion! @roushou Thanks for the feedback. We're on it. 🫡

@roushou
Copy link
Contributor Author

roushou commented Jun 27, 2024

I can help if needed. Just need to make sure we are aligned regarding which path to take.

@Zizzamia
Copy link
Contributor

I guess @roushou, there is an interesting question here which is:

  • is core for all NodeJS stuff, or is more for utils that don't need any other library, like Viem or Wagmi.

I ask this question because I wonder if we should have a import { xyz } from '@coinbase/onchainkit/utils'; which focus on ALL utils, and core is a subset of them.

So the meta question, is how we split between:

  • components
  • hooks
  • utils
  • core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants