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

Question and suggest: The official identifier of Server Compnoent and Client Component #28561

Closed
aofong19871029 opened this issue Mar 15, 2024 · 3 comments

Comments

@aofong19871029
Copy link

As so far , only next.js and react original js support react server componet.

In next.js developer is to being requested to use “use client” to idenfy the react client component , and all of the other js are default to react server component.

In the community find the another way to identity component is to change its file suffix
'.server.js' means this is a server component
'.client.js' means its a client component

So I want to know what is the react official identifier for server component and client component in future?

@aofong19871029 aofong19871029 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 15, 2024
@eps1lon
Copy link
Collaborator

eps1lon commented Mar 15, 2024

.client.js and .server.js was the convention that was proposed originally but later changed to using 'use client' and 'use server' directives instead in reactjs/rfcs#227.

'use client' directive and 'use server' directives are the official convention.

@AntonOshurek
Copy link

Such an approach violates the principle of separation of concerns, as component files should be independent of where they are used (on the server or client). Instead, it's better to strive for creating reusable components that can work seamlessly both on the server and client without modifications.

@eps1lon
Copy link
Collaborator

eps1lon commented Mar 17, 2024

Some components only make sense on the server (e.g. accessing the file system) and need server directives. Most components can be used as both and don't need directives. The linked RFCs go into more detail.

If there are issues with the current approach, I recommend filing a new issue outlining the problems in detail with some examples. Closing this since the original question was answered.

@eps1lon eps1lon closed this as completed Mar 17, 2024
@eps1lon eps1lon removed the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants