You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to build a new app or a new website fully with React, we recommend picking one of the React-powered frameworks popular in the community. Frameworks provide features that most apps and sites eventually need, including routing, data fetching, and generating HTML.
**You need to install [Node.js](https://nodejs.org/en/) for local development.**You can *also* choose to use Node.js in production, but you don't have to. Many React frameworks support export to a static HTML/CSS/JS folder.
13
+
**你需要在你的本機開發環境安裝 [Node.js](https://nodejs.org/en/)。**你*也*可以選擇使用 Node.js 在 production 環境,但你不需要這麼做。許多 React 框架支援匯出靜態的 HTML/CSS/JS 文件。
**[Next.js](https://nextjs.org/)is a full-stack React framework.**It's versatile and lets you create React apps of any size--from a mostly static blog to a complex dynamic application. To create a new Next.js project, run in your terminal:
Next.js is maintained by [Vercel](https://vercel.com/). You can [deploy a Next.js app](https://nextjs.org/docs/deployment) to any Node.js or serverless hosting, or to your own server. [Fully static Next.js apps](https://nextjs.org/docs/advanced-features/static-html-export)can be deployed to any static hosting.
**[Remix](https://remix.run/)is a full-stack React framework with nested routing.**It lets you break your app into nested parts that can load data in parallel and refresh in response to the user actions. To create a new Remix project, run:
If you're new to Remix, check out the Remix [blog tutorial](https://remix.run/docs/en/main/tutorials/blog) (short) and [app tutorial](https://remix.run/docs/en/main/tutorials/jokes) (long).
Remix is maintained by [Shopify](https://www.shopify.com/). When you create a Remix project, you need to [pick your deployment target](https://remix.run/docs/en/main/guides/deployment). You can deploy a Remix app to any Node.js or serverless hosting by using or writing an [adapter](https://remix.run/docs/en/main/other-api/adapter).
**[Gatsby](https://www.gatsbyjs.com/)is a React framework for fast CMS-backed websites.**Its rich plugin ecosystem and its GraphQL data layer simplify integrating content, APIs, and services into one website. To create a new Gatsby project, run:
Gatsby is maintained by [Netlify](https://www.netlify.com/). You can [deploy a fully static Gatsby site](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting) to any static hosting. If you opt into using server-only features, make sure your hosting provider supports them for Gatsby.
**[Expo](https://expo.dev/)is a React framework that lets you create universal Android, iOS, and web apps with truly native UIs.**It provides an SDK for [React Native](https://reactnative.dev/)that makes the native parts easier to use. To create a new Expo project, run:
Expo is maintained by [Expo (the company)](https://expo.dev/about). Building apps with Expo is free, and you can submit them to the Google and Apple app stores without restrictions. Expo additionally provides opt-in paid cloud services.
65
+
Expo 由 [Expo(公司)](https://expo.dev/about)維護。使用 Expo 構建應用程式是免費的,你可以無限制地將它們提交到 Google 和 Apple 應用商店。另外,Expo 還提供可選的付費雲服務。
66
66
67
67
<DeepDive>
68
68
69
-
#### Can I use React without a framework? {/*can-i-use-react-without-a-framework*/}
You can definitely use React without a framework--that's how you'd [use React for a part of your page.](/learn/add-react-to-an-existing-project#using-react-for-a-part-of-your-existing-page)**However, if you're building a new app or a site fully with React, we recommend using a framework.**
Even if you don't need routing or data fetching at first, you'll likely want to add some libraries for them. As your JavaScript bundle grows with every new feature, you might have to figure out how to split code for every route individually. As your data fetching needs get more complex, you are likely to encounter server-client network waterfalls that make your app feel very slow. As your audience includes more users with poor network conditions and low-end devices, you might need to generate HTML from your components to display content early--either on the server, or during the build time. Changing your setup to run some of your code on the server or during the build can be very tricky.
75
+
即使在一開始可能不需要 routing 或是 data fetching,你可能還是想要增加一些相關的函式庫。隨著每個新功能的加入,JavaScript bundle 會越來越大,你可能需要找出如何為每個 routing 單獨拆分程式碼。當 data fetching 需求變得更加複雜時,你可能會遇到 server-client 的 network waterfalls,這會使你的應用程式感覺非常緩慢。當你的使用者中包含了有低速網路和低階設備的受眾時,你可能需要從 component 產成 HTML 以提早顯示內容 - 無論是在伺服器上或在建置期間。更改設定以在伺服器上或在建置期間執行部分程式碼可能非常棘手。
76
76
77
-
**These problems are not React-specific. This is why Svelte has SvelteKit, Vue has Nuxt, and so on.**To solve these problems on your own, you'll need to integrate your bundler with your router and with your data fetching library. It's not hard to get an initial setup working, but there are a lot of subtleties involved in making an app that loads quickly even as it grows over time. You'll want to send down the minimal amount of app code but do so in a single client–server roundtrip, in parallel with any data required for the page. You'll likely want the page to be interactive before your JavaScript code even runs, to support progressive enhancement. You may want to generate a folder of fully static HTML files for your marketing pages that can be hosted anywhere and still work with JavaScript disabled. Building these capabilities yourself takes real work.
**React frameworks on this page solve problems like these by default, with no extra work from your side.**They let you start very lean and then scale your app with your needs. Each React framework has a community, so finding answers to questions and upgrading tooling is easier. Frameworks also give structure to your code, helping you and others retain context and skills between different projects. Conversely, with a custom setup it's easier to get stuck on unsupported dependency versions, and you'll essentially end up creating your own framework—albeit one with no community or upgrade path (and if it's anything like the ones we've made in the past, more haphazardly designed).
If you're still not convinced, or your app has unusual constraints not served well by these frameworks and you'd like to roll your own custom setup, we can't stop you--go for it! Grab`react`and `react-dom` from npm, set up your custom build process with a bundler like [Vite](https://vitejs.dev/)or[Parcel](https://parceljs.org/), and add other tools as you need them for routing, static generation or server-side rendering, and more.
As we've explored how to continue improving React, we realized that integrating React more closely with frameworks (specifically, with routing, bundling, and server technologies) is our biggest opportunity to help React users build better apps. The Next.js team has agreed to collaborate with us in researching, developing, integrating, and testing framework-agnostic bleeding-edge React features like [React Server Components.](/blog/2023/03/22/react-labs-what-we-have-been-working-on-march-2023#react-server-components)
These features are getting closer to being production-ready every day, and we've been in talks with other bundler and framework developers about integrating them. Our hope is that in a year or two, all frameworks listed on this page will have full support for these features. (If you're a framework author interested in partnering with us to experiment with these features, please let us know!)
**[Next.js's App Router](https://beta.nextjs.org/docs/getting-started)is a redesign of the Next.js APIs aiming to fulfill the React team’s full-stack architecture vision.**It lets you fetch data in asynchronous components that run on the server or even during the build.
Next.js is maintained by [Vercel](https://vercel.com/). You can [deploy a Next.js app](https://nextjs.org/docs/deployment) to any Node.js or serverless hosting, or to your own server. Next.js also supports [static export](https://beta.nextjs.org/docs/configuring/static-export) which doesn't require a server.
Next.js's App Router is **currently in beta and is not yet recommended for production** (as of Mar 2023). To experiment with it in an existing Next.js project, [follow this incremental migration guide](https://beta.nextjs.org/docs/upgrade-guide#migrating-from-pages-to-app).
#### Which features make up the React team’s full-stack architecture vision? {/*which-features-make-up-the-react-teams-full-stack-architecture-vision*/}
Next.js's App Router bundler fully implements the official [React Server Components specification](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md). This lets you mix build-time, server-only, and interactive components in a single React tree.
105
+
Next.js 的 App Router bundler 完全實作了官方的 [React Server Components 規範](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md)。這讓你可以在單個 React tree 中混合 build-time、server-only 和和互動式元件。
106
106
107
-
For example, you can write a server-only React component as an `async`function that reads from a database or from a file. Then you can pass data down from it to your interactive components:
// This component runs *only* on the server (or during the build).
@@ -120,14 +120,14 @@ async function Talks({ confId }) {
120
120
}
121
121
```
122
122
123
-
Next.js's App Router also integrates [data fetching with Suspense](/blog/2022/03/29/react-v18#suspense-in-data-frameworks). This lets you specify a loading state (like a skeleton placeholder) for different parts of your user interface directly in your React tree:
123
+
Next.js 的 App Router 也整合了[使用 Suspense 進行 data fetching](/blog/2022/03/29/react-v18#suspense-in-data-frameworks)。這讓你可以直接在 React tree 中為使用者介面不同部分指定載入狀態(例如:skeleton placeholder):
124
124
125
125
```js
126
126
<Suspense fallback={<TalksLoading />}>
127
127
<Talks confId={conf.id} />
128
128
</Suspense>
129
129
```
130
130
131
-
Server Components and Suspense are React features rather than Next.js features. However, adopting them at the framework level requires buy-in and non-trivial implementation work. At the moment, the Next.js App Router is the most complete implementation. The React team is working with bundler developers to make these features easier to implement in the next generation of frameworks.
0 commit comments