GitXplorerGitXplorer
s

react-server-components-playground

public
145 stars
7 forks
0 issues

Commits

List of commits on branch main.
Verified
3f58a640961d0079276e98c39e67c46c4f7c4c20

fix link

ssibelius committed 4 years ago
Verified
4e7e971e0db84f223008e780217c7a7f5c4d5ac5

ssr note

ssibelius committed 4 years ago
Verified
f52d745b4e2449e529eb2534ec96ce4672ed5fb5

Update README.md

ssibelius committed 4 years ago
Verified
c8ca945635113c9737befc1f3a7b471df7814eb3

Merge pull request #4 from gaearon/patch-1

ssibelius committed 4 years ago
Verified
7f0a0c134aedeb844a1df41b07a50a9cf49a781b

Clarify that it's not production-ready

ggaearon committed 4 years ago
Verified
47da5ef9ad303dd5a6d0aa26bfa1826e79bbed3d

Merge pull request #3 from sibelius/feat/server

ssibelius committed 4 years ago

README

The README file for this repository.

React Server Components Playground (Not for Production)

This is a React Server Components Playground to make it easy to experiment with Server Components

it is based on server-components-demo

Can I use this in production?

🔴 🔴 🔴 Oh dear, no. Please, DO NOT use this in production! 🔴 🔴 🔴

As stated on the React blog, Server Components are an early experimental tech preview, and are nowhere close to being usable or supported for production apps today.

This boilerplate is not developed by the React team, and does not represent how Server Components will actually be integrated by the time they are stable. Instead, the first high-quality integrations will be developed in collaboration with React frameworks.

Does this solve SSR?

Not yet, maybe in the future. For SSR check this react-webpack-ssr-boilerplate, it is the simplest React SSR Boilerplate out there. It is just 2 webpack (client and server)

How to start

Run the plugin and loader transpilation using babel

yarn plugin

Run the Client and Server Bundler at the same time

yarn start

Some explanations

./plugin folder has some copied and modified react-server-dom-webpack files

ReactFlightWebpackPlugin modifications

  • Be able to have client references using Typescript

ReactFlightWebpackLoader

  • A loader to be used on the server to transform client references
  • It is similar to ReactFlightWebpackNodeRegister
  • This enable avoiding transpiling on the fly in production
{
        test: /\.client.(js|jsx|ts|tsx)?$/,
        use: [{
          loader: require.resolve('./plugin/ReactFlightWebpackLoader'),
        }, {
          loader: 'babel-loader?cacheDirectory',
        }],
        exclude: [
          /node_modules/,
          path.resolve(__dirname, '.serverless'),
          path.resolve(__dirname, '.webpack'),
        ],
      },