Nodejs 最新全栈解决方案 Nodejs Fullstack Solution
JamStack
These decisions include the following:
- How you’ll manage the project/code
- Where you’ll store your content
- What software will build your site
- How your build process will be automated
- Where your site will be published
- What services and APIs your live site will use
Best Practices
- Entire Project on a CDN
- Modern Build Tools
- Automated Builds
- Atomic Deploys: No changes go live until all changed files have been uploaded.
- Instant Cache Invalidation: Making sure your CDN can handle instant cache purges.
- Everything Lives in Git: Git clone, install any needed dependencies with a standard procedure (like npm install), and be ready to run the full project locally. No databases to clone, no complex installs.
History
LAMP(Linux, Apache, MySQL, PHP/Perl/Python) stack —> MEAN(MongoDB, Express.js, Angular/React/Vue, and Node.js) stack —> JAM(JavaScript, APIs and Markup) stack
The Fullstack React Framework
Blitz = Next.js + React Hook Form + Prisma.js 中文站
- Blitz is inspired by Ruby on Rails, and built on [[#NextJS|tag.NextJS]], [[#prisma|tag.prisma]], [[#SQLite|tag.SQLite]], [[#GraphQL|tag.GraphQL]]. Why use Blitz instead of Next.js?
- Fullstack instead of Frontend
- Data Layer: - You don’t need to build an API and do data fetching from the frontend. - Essentially, Blitz abstracts your API into a compile step. - You can continue doing data fetching via REST or GraphQL like you’ve always done. - Blitz doesn’t restrict this in any way.
- Built-in Authentication
- Conventions: Blitz brings a number of conventions for things like how to organize your files and how to structure your routes.
- Code Scaffolding not code generation, Blitz is a huge fan of code scaffolding and in the future will add your own custom scaffold templates.
- Recipes are one-line commands for scaffolding code into your project from an MDX recipe on npm or a git repository. They are written via MDX and can be composed like React components.
-
blitz install tailwind
tailwind CSS 工具式 class 风格的 CSS 库 -blitz install material-ui
MATERIAL-UI 中文版 Google 推出的 UI 组件库 - New App Development: Set up okay for eslint, prettier, husky git hooks, etc.
- Relaxed Restrictions: You can separate and organize your pages in any way you want. Examples:
-
app/pages/
could contain the homepage and pages like “about” -app/products/pages/
could contain all the pages related to products -app/admin/pages/
could contain all pages related to the backend admin section - Building a fullstack React application with Blitz.js.
基于 Blitz 开发的项目
- Awesome Blitz.js
- Quirrel makes job queues simple as cake.
- Flitz.dev 日本的一个微博客社区,源码:Github,需要 docker-compose 安装 PostgreSQL 数据库。
- Recipe App 一个很简单的食谱 App,就三个字段:名称、描述和上传图片。
- Kalle.app 一个会议管理的 App demo,源码: Github
RedwoodJS
- RedwoodJS Bringing full-stack to the Jamstack. Built on React, GraphQL, and Prisma
- Using Storybook for components display.
- self-hosting-redwood
- Login [[#Netlify|tag.Netlify]] by Github account.
- build a full stack application using redwood
Blitz.js vs. RedwoodJS
-
Blitz.js
- Blitz.js enables you to request the database from the client itself using Prisma.
- For data management on the client side, Blitz uses React Query under the hood
- Blitz uses Prisma to manage the database connection and schemas.
-
Redwood.js
- Redwood uses Prisma to connect with the database. Once it fetches the data, it returns to the client.
- Redwood follows the monorepo pattern. To add any library to the client or server side, use the following command.
yarn workspace web add react-query yarn workspace api add jsonwebtoken
-
结论: 作者更倾向于 Blitz.js,因为不限制使用 GraphQL,二者都可以快速开发。
React frameworks: Redwood vs Blitz
- Redwood is built on React, GraphQL, and Prisma.
- Blitz is built on top of Next.js (which is built on top of React)
- What I noticed is Redwood using js, ts is development, but Blitz using ts.
Vue
Gridsome A Jamstack framework for Vue.js
Blitz.js 选择哪个 Form 框架呢?
- React Final Form (which released two years ago. 2019-10-30) gzipped 3.3kB + 5.4kB (Final Form)
- Final Form gzipped 5.4kB
- 作者原来维护 Redux Form,改正了很多错误。 (which released four years ago. 2019-10-30) gzipped 22.5kB
- 是通用的,不信赖任何框架的,因为之后出了 Hooks,所以独立出了 React Final Form。
- React Final Form HTML5 Validation 针对H5的 Form 检验功能
- Final Form gzipped 5.4kB
- Formik Build forms in React, without the tears. gzipped 12.7kB.
- React Hook Form (which released seven months ago. 2019-10-30) 仅是 Formik 一半大小
- React Hook Form vs. Formik: A technical and performance comparison 2019-10-30
- Conclution: React Hook Form win!
- A comparison of formik, final-form and react-hook-form
- Conclution: React Hook Form win!
- Formik VS React Hook Form Part I
- Formik vs React-hook-form Cases Part II
结论:
- Formik 不用考虑了,上面有些比较的文章已经说明不如 React Hook Form
- Final Form 国内访问不到
- React Hook Form 可以,且有中文