All Projects → vercel → Next Server Components

vercel / Next Server Components

Licence: mit
Experimental demo of React Server Components with Next.js. Deployed serverlessly on Vercel.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Next Server Components

Next On Netlify
Build and deploy Next.js applications with Server-Side Rendering on Netlify!
Stars: ✭ 719 (+61.94%)
Mutual labels:  serverless, nextjs
Serverless Next
How to use Serverless to provide the frontend with a full API with minimal effort and max. scalability
Stars: ✭ 41 (-90.77%)
Mutual labels:  serverless, nextjs
Commercejs Nextjs Demo Store
Commerce demo store built for the Jamstack. Built with Commerce.js, Next.js, and can be one-click deployed to Netlify. Includes product catalog, categories, variants, cart, checkout, payments (Stripe) order confirmation, and printable receipts.
Stars: ✭ 737 (+65.99%)
Mutual labels:  serverless, nextjs
Firebase Gcp Examples
🔥 Firebase app architectures, languages, tools & some GCP things! React w Next.js, Svelte w Sapper, Cloud Functions, Cloud Run.
Stars: ✭ 470 (+5.86%)
Mutual labels:  serverless, nextjs
Nextjs Pwa Graphql Sql Boilerplate
Next.js serverless PWA with GraphQL (Apollo) + Postgres SQL boilerplate
Stars: ✭ 125 (-71.85%)
Mutual labels:  serverless, nextjs
Moveit
🚀 NLW #4 | React+ TypeScript + NextJS + StyledComponents + Firebase + MongoDb +Axios
Stars: ✭ 39 (-91.22%)
Mutual labels:  serverless, nextjs
Terraform Nextjs Plugin
A plugin to generate terraform configuration for Nextjs 8 and 9
Stars: ✭ 41 (-90.77%)
Mutual labels:  serverless, nextjs
Next Starter
Next.js Starter using GraphQL, MobX (Next.js, TypeScript, Babel, Express.js, Apollo Client, React Apollo, React Apollo Hooks, GraphQL Codegen, MobX, mobx-state-tree, styled-components, next-optimized-images, Serverless Framework, AWS Lambda, Dotenv)
Stars: ✭ 90 (-79.73%)
Mutual labels:  serverless, nextjs
Jamstack Ecommerce
A starter project for building performant ECommerce applications with Next.js and React
Stars: ✭ 1,384 (+211.71%)
Mutual labels:  serverless, nextjs
Serverless With Next5 Boilerplate
Serverless.js with Next.js 5 on AWS, powered by the Serverless Framework
Stars: ✭ 100 (-77.48%)
Mutual labels:  serverless, nextjs
Terraform Aws Next Js
Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.
Stars: ✭ 163 (-63.29%)
Mutual labels:  serverless, nextjs
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+570.5%)
Mutual labels:  serverless, nextjs
Timelite
Why is it 5 AM? Isn't there something simple I can use to track what I'm doing with all this time?
Stars: ✭ 201 (-54.73%)
Mutual labels:  serverless, nextjs
Serverless Libreoffice
Run LibreOffice in AWS Lambda to create PDFs & convert documents
Stars: ✭ 410 (-7.66%)
Mutual labels:  serverless
Guide
Serverless Guide - An open-source definitive guide to serverless architectures.
Stars: ✭ 421 (-5.18%)
Mutual labels:  serverless
Faaslang
FaaSlang defines FaaS execution semantics and type-safety mechanisms
Stars: ✭ 405 (-8.78%)
Mutual labels:  serverless
Faasm
High-performance stateful serverless runtime based on WebAssembly
Stars: ✭ 403 (-9.23%)
Mutual labels:  serverless
Next Sitemap
Sitemap generator for next.js. Generate sitemap(s) and robots.txt for all static/pre-rendered/dynamic/server-side pages.
Stars: ✭ 426 (-4.05%)
Mutual labels:  nextjs
Gh Board
"Serverless" Kanban for GitHub Issues using gh-pages
Stars: ✭ 420 (-5.41%)
Mutual labels:  serverless
Cli
CLI tool for dead-simple serverless Docker deployments on managed Kubernetes services. A self-hosted PaaS. ⚡️
Stars: ✭ 400 (-9.91%)
Mutual labels:  serverless

React Server Components in Next.js

Experimental app of React Server Components with Next.js, based on React Server Components Demo.
It's not ready for adoption. Use this in your projects at your own risk.

Development

Prepare

You need these environment variables to run this app (you can create a .env file):

REDIS_URL='rediss://:<password>@<url>:<port>' // or `redis://` if no TLS
ENDPOINT='http://localhost:3000'              // need to be absolute url to run in prod/local
NEXT_PUBLIC_ENDPOINT='http://localhost:3000'  // same as above
SESSION_KEY='<random key for cookie-based session>'
OAUTH_CLIENT_KEY='github oauth app id'
OAUTH_CLIENT_SECRET='github oauth app secret'

Start

  1. yarn install (this will trigger the postinstall command)
  2. yarn dev

Go to localhost:3000 to view the application.

Deploy

Deploy with Vercel

Caveats

  • Only .js extension is supported.
  • Client / server components should be under the components directory.
  • Some React Hooks are not supported in server components, such as useContext.
  • You have to manually import React in your server components.

How does it work?

Application APIs:

  • GET, POST /api/notes (Get all notes, Create a new note)
  • GET, PUT, DELETE /api/notes/<note_id> (Action for a specific note)

React Server Components API (pages/api/index.js):

  • GET /api (render application and return the serialized components)

Note: Some of the application APIs (POST, PUT, DELETE) will render and return the serialized components as well. The render logic is handled by libs/send-res.js.

libs/send-res.js accepts the props (from req.query.location and req.session.login) that needs to be rendered by components/App.server.js (the component tree entry). Then, it renders the tree and streams it to res using:

pipeToNodeWritable(React.createElement(App, props), res, moduleMap)

moduleMap is generated by client-side Webpack (through Next.js). It traverses both .server.js and .client.js and generates the full module map from the react-server-dom-webpack/plugin Webpack plugin (see next.config.js). Then, we use a custom plugin to copy it to libs/react-client-manifest.json and include it from the lambdas (see libs/send-res-with-module-map.js).

App is a special build of components/App.server.js, which removes all the client components (marked as special modules) because they're not accessible from the server. We bundled it together with libs/send-res.js with another Webpack loader into libs/send-res.build.js. The Webpack script and loader are under scripts/. It should run whenever a server component is updated.

Finally, everything related to OAuth is inside pages/api/auth.js. It's a cookie-based session using GitHub for login.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].