Skip to content

Use case: co-locating server and client code #80

Open
@nicolo-ribaudo

Description

@nicolo-ribaudo

Different frameworks are moving towards co-location of code that runs on the server and on the client. Some examples are React with "use server"/"use client", Qwik with server$, and Solid with server$.

They all use functions, that can have confusing behaviors because they can close over variables "from the server to the client" and vice versa. Module expression would give a clear boundary:

// Rendered on server
function MyButton() {
  return (
    <button onClick={module {
      // Running on client
      export default () => alert("Clicked!");
    }>
      {fs.readFileSync("./btn-text")}
    </button>
  );
}

This might be another good use case for the shorthand syntax (#59)

(cc @ryansolid thanks for the idea!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions