Ryan Carniato
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    3
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Isomorphic First Framework Seeing the reception to SvelteKit Remote functions and Tanstack Start I realize I probably should codify the architecture we designed on stream. It is important to differentiate this architecture from Server First which has dominated the conversation the past few years. And this will probably help us decide where to take things next. ## So what do I mean by Isomorphic First? I mean an architecture that at its core runs on both server and client. This differs from classic Marko, Astro, Next.js, Remix 3, Fresh, etc... It's base expectation is code can run either side. SPAs with SSR are like this. Qwik is like this. You can also view this whole thing as client first, but the fact code can run on both sides is important to its identity. The benefit of this model is it reflects the reality of how apps behave after initial load. As much as we create a full page reload mental model with Server First frameworks, the client ofetn manages the routing in these tools as things evolve. It persists state. It is easier to approach from a SPA perspective because you don't need to reverse your thinking. You don't need to uppend your app from the root. More so interactions with the server stay granular. While waterfalls are a risk that is no different than client today. And we can do somethings to help safeguard that. Finally if isomorphic is your base, then client/shared components don't need special denotation. It's only things that run in a specific environment that need to be identified. `use server` means server only. `use worker` means that. Maybe `use prerender`. The use of directives doesn't matter, prefer file extensions it is the same thing. ## This Architecure is Doing Great Today Isomorphic Preloaders, Server Function (or Remote Functions if you prefer), better non-blocking async Reactivity with concurrency, Streaming SSR. These pieces all allow this architecture to flourish today. We've added things like optimistic updates (thank you Remix), and things like Single Flight Mutations. Today the modern take that started with [SolidStart](https://start.solidjs.com/)(See my talks from Vite Conf the past 3 years[[2022](https://www.youtube.com/watch?v=G5vwaoXck_g&list=PL16vUvov3c5D1_KlYevpriA9QMkVkY32l), [2023](https://youtu.be/XMybh3gCmQ0?si=CRNr-K1FvXw0QUbk), [2024](https://youtu.be/S0-fhGskPYA?si=LwBBoX64pz48l81u)] or where I put it all together and made my called shot [The Shape of Frameworks to Come](https://www.youtube.com/watch?v=ZVjXtfdKQ3g)) is available in both Svelte and React as well via SvelteKit and Tanstack Start. Cosmetic differences but essentially the same architecture which is just an evolution of the SPAs we've always made. ## So no Server Components? Not necessarily. There is server only code. You could have a Server Function return dynamic HTML templates. I wrote [Are Lakes Real?](https://hackmd.io/@0u1u3zEAQAO0iYWVAStEvw/SJo9se7XJx) a while back to show a model where you could do Server Components with all their benefits with an isomorphic first approach. To be fair it is just as complicated and challenging as any other Server Component solution but it is a thing. I've been skeptical of Lakes in general because it is easy to cause Server => Client => Server waterfalls. However to be fair this is a problem in all Client first architectures and we've been doing just fine with that for over a decade. I realized as I talked to Tanner more about this approach the key to it is seperating the templating from the data needed to render. The reason one can end up with incidental waterfalls so easily is if the interface is just a Component, just something you pass props to it isn't obviously how your composition impacts things. Whereas if Server Components are something you return from Server Functions all the patterns we've classically had to hoist still work. (Keep in mind these aren't the final APIs, just to illustrate). ```jsx async function getMyServerComponent(id, { children }: { children: JSX.Element }) { "use server" const data = await db.getSomething(id); return <div id="server"> {data} {children} </div> } function App(props) { // wrapper over `createAsync` const Server = createServerComponent(() => getMyServerComponent(props.id)); return ( <Server> <div id="client">Hello</div> </Server> ) } ``` One could preload their Server function in the route preloader, they could call multiple at the top of the their components. But the important part is the children projections, slotting/props will never cause a Server component to re-render. The View code doesn't cause re-renders but the fetching does. You have to update the `use` or the underlying `createAsync`. I think this while subtle is a huge difference over just naively importing Server components in Client scope or using abstractions like `<Frame>` to do HTML partials because those generally tie the mechanism to the UI. And the thing is the Server Component can pass arguments back to the client by render props. I covered that in my other writeup, so yes it does compose back and forth. The fundamental difference though is the client is a single tree and the server isn't. Which can in theory cause waterfalls, but also means we aren't beholden to reloading the full page, or full route section to update parts from the server. You get partials without having to mark the client side coming back in. No `use client` or `island` or `hydrated`. Sure no one has done this today, but I like that there is a path forward that is consistent with the mental model. ## To the Future I wrote this up because I wanted to call out this pattern. I want to acknowledge it so that we can build upon it. Server Components is one direction here. Resumability is another. These aren't mutually exclusive. What they share is a view that you are trying to build one app. Now it might seem weird to attempt that on top of the web which is clearly a Server/Client model. But of those two, for most infrastructure, only one side keeps the persistent connection. This does sort of double down on local first mentality of the client being a source of truth. This is not HTMX or PHP, this is the evolution of the SPA. Straddling the line is hard. As much as we should recognize leveraging the server more improves initial load considerations, leveraging the client more improves interactive potential. What's interesting to me is whenever we move closer to the server there is this tension to use non-JS on the backend which feels real. Like render your Server Components in Go. Where this pretty much flies in the face of that a bit given the SPA is the base. But on the otherhand Server Functions could be done in a different language as long as they could serialize the same. Doesn't help with SSR admittedly but it is interesting. I wonder if there is a future where things marked with `use server` just get deployed to a different server closer to the DB and the rest goes to the edge or the browser. Atleast there is no ambiguity there.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully