Skip to content

Commit d38e359

Browse files
committed
Merge branch 'main' into sync-50d6991c
2 parents 7ff7f07 + fd093ad commit d38e359

File tree

1 file changed

+55
-53
lines changed

1 file changed

+55
-53
lines changed

src/content/reference/rsc/server-components.md

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
---
2-
title: Server Components
2+
title: "Komponen Server"
33
---
44

55
<RSC>
66

7-
Server Components are for use in [React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks).
7+
Komponen Server digunakan di [Komponen Server React](/learn/start-a-new-react-project#bleeding-edge-react-frameworks).
88

99
</RSC>
1010

1111
<Intro>
1212

13-
Server Components are a new type of Component that renders ahead of time, before bundling, in an environment separate from your client app or SSR server.
13+
Komponen Server adalah jenis Komponen baru yang dirender terlebih dahulu, sebelum proses bundling, di lingkungan yang terpisah dari aplikasi klien atau server SSR Anda.
14+
1415

1516
</Intro>
1617

17-
This separate environment is the "server" in React Server Components. Server Components can run once at build time on your CI server, or they can be run for each request using a web server.
18+
Lingkungan terpisah ini adalah "server" dalam Komponen Server React. Komponen Server dapat dijalankan sekali saat build di server CI Anda, atau dapat dijalankan untuk setiap permintaan menggunakan web server.
1819

1920
<InlineToc />
2021

2122
<Note>
2223

23-
#### How do I build support for Server Components? {/*how-do-i-build-support-for-server-components*/}
2424

25-
While React Server Components in React 19 are stable and will not break between minor versions, the underlying APIs used to implement a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x.
25+
#### Bagaimana cara membangun dukungan untuk Komponen Server? {/*how-do-i-build-support-for-server-components*/}
26+
27+
Meskipun Komponen Server React di React 19 sudah stabil dan tidak akan rusak antar versi mayor, API dasar yang digunakan untuk mengimplementasikan bundler atau framework Komponen Server React tidak mengikuti semver dan dapat berubah antar versi minor di React 19.x.
2628

27-
To support React Server Components as a bundler or framework, we recommend pinning to a specific React version, or using the Canary release. We will continue working with bundlers and frameworks to stabilize the APIs used to implement React Server Components in the future.
29+
Untuk mendukung Komponen Server React sebagai bundler atau framework, kami merekomendasikan untuk mengunci ke versi React tertentu, atau menggunakan rilis Canary. Kami akan terus bekerja sama dengan bundler dan framework untuk menstabilkan API yang digunakan untuk mengimplementasikan Komponen Server React di masa mendatang.
2830

2931
</Note>
3032

31-
### Server Components without a Server {/*server-components-without-a-server*/}
32-
Server components can run at build time to read from the filesystem or fetch static content, so a web server is not required. For example, you may want to read static data from a content management system.
33+
### Komponen Server tanpa Server {/*server-components-without-a-server*/}
34+
Komponen server dapat dijalankan saat proses build untuk membaca dari filesystem atau mengambil konten statis, sehingga web server tidak diperlukan. Sebagai contoh, Anda mungkin ingin membaca data statis dari sistem manajemen konten.
3335

34-
Without Server Components, it's common to fetch static data on the client with an Effect:
36+
Tanpa Komponen Server, biasanya data statis diambil di klien menggunakan Effect:
3537
```js
3638
// bundle.js
3739
import marked from 'marked'; // 35.9K (11.2K gzipped)
3840
import sanitizeHtml from 'sanitize-html'; // 206K (63.3K gzipped)
3941

4042
function Page({page}) {
4143
const [content, setContent] = useState('');
42-
// NOTE: loads *after* first page render.
44+
// CATATAN: dimuat *setelah* render pertama halaman.
4345
useEffect(() => {
4446
fetch(`/api/content/${page}`).then((data) => {
4547
setContent(data.content);
@@ -58,56 +60,56 @@ app.get(`/api/content/:page`, async (req, res) => {
5860
});
5961
```
6062

61-
This pattern means users need to download and parse an additional 75K (gzipped) of libraries, and wait for a second request to fetch the data after the page loads, just to render static content that will not change for the lifetime of the page.
63+
Pola ini berarti pengguna perlu mengunduh dan mengurai tambahan pustaka sebesar 75K (gzipped), dan menunggu permintaan kedua untuk mengambil data setelah halaman dimuat, hanya untuk merender konten statis yang tidak akan berubah selama masa hidup halaman.
6264

63-
With Server Components, you can render these components once at build time:
65+
Dengan Komponen Server, Anda dapat merender komponen ini sekali saat proses build:
6466

6567
```js
66-
import marked from 'marked'; // Not included in bundle
67-
import sanitizeHtml from 'sanitize-html'; // Not included in bundle
68+
import marked from 'marked'; // Tidak termasuk dalam bundel
69+
import sanitizeHtml from 'sanitize-html'; // Tidak termasuk dalam bundel
6870

6971
async function Page({page}) {
70-
// NOTE: loads *during* render, when the app is built.
72+
// CATATAN: dimuat *saat* render, ketika aplikasi dibangun.
7173
const content = await file.readFile(`${page}.md`);
7274

7375
return <div>{sanitizeHtml(marked(content))}</div>;
7476
}
7577
```
7678

77-
The rendered output can then be server-side rendered (SSR) to HTML and uploaded to a CDN. When the app loads, the client will not see the original `Page` component, or the expensive libraries for rendering the markdown. The client will only see the rendered output:
79+
Output yang dirender kemudian dapat dirender di sisi server (SSR) ke HTML dan diunggah ke CDN. Ketika aplikasi dimuat, klien tidak akan melihat komponen `Page` yang asli, atau pustaka mahal untuk merender markdown. Klien hanya akan melihat output yang dirender:
7880

7981
```js
8082
<div><!-- html for markdown --></div>
8183
```
8284

83-
This means the content is visible during first page load, and the bundle does not include the expensive libraries needed to render the static content.
85+
Ini berarti konten terlihat selama pemuatan halaman pertama, dan bundel tidak menyertakan pustaka mahal yang diperlukan untuk merender konten statis.
8486

8587
<Note>
8688

87-
You may notice that the Server Component above is an async function:
89+
Anda mungkin memperhatikan bahwa Komponen Server di atas adalah fungsi async:
8890

8991
```js
9092
async function Page({page}) {
9193
//...
9294
}
9395
```
9496

95-
Async Components are a new feature of Server Components that allow you to `await` in render.
97+
Komponen Async adalah fitur baru dari Komponen Server yang memungkinkan Anda untuk `await` saat merender.
9698

97-
See [Async components with Server Components](#async-components-with-server-components) below.
99+
Lihat [Komponen Async dengan Komponen Server](#async-components-with-server-components) di bawah ini.
98100

99101
</Note>
100102

101-
### Server Components with a Server {/*server-components-with-a-server*/}
102-
Server Components can also run on a web server during a request for a page, letting you access your data layer without having to build an API. They are rendered before your application is bundled, and can pass data and JSX as props to Client Components.
103+
### Komponen Server dengan Server {/*server-components-with-a-server*/}
104+
Komponen Server juga dapat dijalankan di web server saat ada permintaan untuk sebuah halaman, sehingga Anda dapat mengakses data secara langsung tanpa perlu membangun API. Komponen ini dirender sebelum aplikasi Anda dibundel, dan dapat meneruskan data serta JSX sebagai props ke Komponen Klien.
103105

104-
Without Server Components, it's common to fetch dynamic data on the client in an Effect:
106+
Tanpa Komponen Server, biasanya data dinamis diambil di klien menggunakan Effect:
105107

106108
```js
107109
// bundle.js
108110
function Note({id}) {
109111
const [note, setNote] = useState('');
110-
// NOTE: loads *after* first render.
112+
// CATATAN: dimuat *setelah* render pertama.
111113
useEffect(() => {
112114
fetch(`/api/notes/${id}`).then(data => {
113115
setNote(data.note);
@@ -124,8 +126,8 @@ function Note({id}) {
124126

125127
function Author({id}) {
126128
const [author, setAuthor] = useState('');
127-
// NOTE: loads *after* Note renders.
128-
// Causing an expensive client-server waterfall.
129+
// CATATAN: dimuat *setelah* Note dirender.
130+
// Menyebabkan waterfall client-server yang mahal.
129131
useEffect(() => {
130132
fetch(`/api/authors/${id}`).then(data => {
131133
setAuthor(data.author);
@@ -150,13 +152,13 @@ app.get(`/api/authors/:id`, async (req, res) => {
150152
});
151153
```
152154

153-
With Server Components, you can read the data and render it in the component:
155+
Dengan Komponen Server, Anda dapat membaca data dan merendernya langsung di komponen:
154156

155157
```js
156158
import db from './database';
157159

158160
async function Note({id}) {
159-
// NOTE: loads *during* render.
161+
// CATATAN: dimuat *saat* render.
160162
const note = await db.notes.get(id);
161163
return (
162164
<div>
@@ -167,14 +169,14 @@ async function Note({id}) {
167169
}
168170

169171
async function Author({id}) {
170-
// NOTE: loads *after* Note,
171-
// but is fast if data is co-located.
172+
// CATATAN: dimuat *setelah* Note,
173+
// tapi akan cepat jika data berdekatan.
172174
const author = await db.authors.get(id);
173175
return <span>By: {author.name}</span>;
174176
}
175177
```
176178

177-
The bundler then combines the data, rendered Server Components and dynamic Client Components into a bundle. Optionally, that bundle can then be server-side rendered (SSR) to create the initial HTML for the page. When the page loads, the browser does not see the original `Note` and `Author` components; only the rendered output is sent to the client:
179+
Bundler kemudian akan menggabungkan data, Komponen Server yang sudah dirender, dan Komponen Klien dinamis ke dalam satu bundel. Opsional, bundel ini bisa dirender di sisi server (SSR) untuk membuat HTML awal halaman. Saat halaman dimuat, browser tidak akan melihat komponen `Note` dan `Author` asli; hanya output yang sudah dirender yang dikirim ke klien:
178180

179181
```js
180182
<div>
@@ -183,26 +185,26 @@ The bundler then combines the data, rendered Server Components and dynamic Clien
183185
</div>
184186
```
185187

186-
Server Components can be made dynamic by re-fetching them from a server, where they can access the data and render again. This new application architecture combines the simple “request/response” mental model of server-centric Multi-Page Apps with the seamless interactivity of client-centric Single-Page Apps, giving you the best of both worlds.
188+
Komponen Server dapat dibuat dinamis dengan mengambil ulang dari server, sehingga dapat mengakses data dan merender ulang. Arsitektur aplikasi baru ini menggabungkan model mental “request/response” sederhana dari Multi-Page Apps berbasis server dengan interaktivitas mulus dari Single-Page Apps berbasis klien, memberikan Anda keunggulan dari kedua dunia.
187189

188-
### Adding interactivity to Server Components {/*adding-interactivity-to-server-components*/}
190+
### Menambahkan interaktivitas ke Komponen Server {/*adding-interactivity-to-server-components*/}
189191

190-
Server Components are not sent to the browser, so they cannot use interactive APIs like `useState`. To add interactivity to Server Components, you can compose them with Client Component using the `"use client"` directive.
192+
Komponen Server tidak dikirim ke browser, jadi mereka tidak dapat menggunakan API interaktif seperti `useState`. Untuk menambahkan interaktivitas ke Komponen Server, Anda dapat menggabungkannya dengan Komponen Klien menggunakan direktif `"use client"`.
191193

192194
<Note>
193195

194-
#### There is no directive for Server Components. {/*there-is-no-directive-for-server-components*/}
196+
#### Tidak ada direktif untuk Komponen Server. {/*there-is-no-directive-for-server-components*/}
195197

196-
A common misunderstanding is that Server Components are denoted by `"use server"`, but there is no directive for Server Components. The `"use server"` directive is used for Server Functions.
198+
Sebuah kesalahpahaman umum adalah bahwa Komponen Server ditandai dengan `"use server"`, tetapi tidak ada direktif untuk Komponen Server. Direktif `"use server"` digunakan untuk Fungsi Server.
197199

198-
For more info, see the docs for [Directives](/reference/rsc/directives).
200+
Untuk info lebih lanjut, lihat dokumen untuk [Directives](/reference/rsc/directives).
199201

200202
</Note>
201203

202204

203-
In the following example, the `Notes` Server Component imports an `Expandable` Client Component that uses state to toggle its `expanded` state:
205+
Dalam contoh berikut, Komponen Server `Notes` mengimpor Komponen Klien `Expandable` yang menggunakan state untuk mengubah status `expanded`:
204206
```js
205-
// Server Component
207+
// Komponen Server
206208
import Expandable from './Expandable';
207209

208210
async function Notes() {
@@ -219,7 +221,7 @@ async function Notes() {
219221
}
220222
```
221223
```js
222-
// Client Component
224+
// Komponen Klien
223225
"use client"
224226

225227
export default function Expandable({children}) {
@@ -237,7 +239,7 @@ export default function Expandable({children}) {
237239
}
238240
```
239241

240-
This works by first rendering `Notes` as a Server Component, and then instructing the bundler to create a bundle for the Client Component `Expandable`. In the browser, the Client Components will see output of the Server Components passed as props:
242+
Ini bekerja dengan pertama-tama merender `Notes` sebagai Komponen Server, dan kemudian menginstruksikan bundler untuk membuat bundel untuk Komponen Klien `Expandable`. Di browser, Komponen Klien akan melihat output dari Komponen Server yang diteruskan sebagai props:
241243

242244
```js
243245
<head>
@@ -257,21 +259,21 @@ This works by first rendering `Notes` as a Server Component, and then instructin
257259
</body>
258260
```
259261

260-
### Async components with Server Components {/*async-components-with-server-components*/}
262+
### Komponen Async dengan Komponen Server {/*async-components-with-server-components*/}
261263

262-
Server Components introduce a new way to write Components using async/await. When you `await` in an async component, React will suspend and wait for the promise to resolve before resuming rendering. This works across server/client boundaries with streaming support for Suspense.
264+
Komponen Server memperkenalkan cara baru untuk menulis Komponen menggunakan async/await. Ketika Anda `await` di dalam komponen async, React akan suspend dan menunggu promise untuk diselesaikan sebelum melanjutkan rendering. Ini bekerja di seluruh batas server/klien dengan dukungan streaming untuk Suspense.
263265

264-
You can even create a promise on the server, and await it on the client:
266+
Anda bahkan dapat membuat promise di server, dan menunggunya di klien:
265267

266268
```js
267-
// Server Component
269+
// Komponen Server
268270
import db from './database';
269271

270272
async function Page({id}) {
271-
// Will suspend the Server Component.
273+
// Akan suspend Komponen Server.
272274
const note = await db.notes.get(id);
273275

274-
// NOTE: not awaited, will start here and await on the client.
276+
// CATATAN: tidak ditunggu, akan mulai di sini dan menunggu di klien.
275277
const commentsPromise = db.comments.get(note.id);
276278
return (
277279
<div>
@@ -285,18 +287,18 @@ async function Page({id}) {
285287
```
286288

287289
```js
288-
// Client Component
290+
// Komponen Klien
289291
"use client";
290292
import {use} from 'react';
291293

292294
function Comments({commentsPromise}) {
293-
// NOTE: this will resume the promise from the server.
294-
// It will suspend until the data is available.
295+
// CATATAN: ini akan melanjutkan promise dari server.
296+
// Ini akan suspend sampai data tersedia.
295297
const comments = use(commentsPromise);
296298
return comments.map(commment => <p>{comment}</p>);
297299
}
298300
```
299301

300-
The `note` content is important data for the page to render, so we `await` it on the server. The comments are below the fold and lower-priority, so we start the promise on the server, and wait for it on the client with the `use` API. This will Suspend on the client, without blocking the `note` content from rendering.
302+
Konten `note` adalah data penting untuk merender halaman, jadi kami `await` di server. Komentar berada di bawah lipatan dan memiliki prioritas lebih rendah, jadi kami memulai promise di server, dan menunggunya di klien dengan API `use` tersebut. Ini akan Suspend di klien, tanpa memblokir konten `note` untuk dirender.
301303

302-
Since async components are not supported on the client, we await the promise with `use`.
304+
Karena komponen async tidak didukung di klien, kita menunggu promise dengan `use`.

0 commit comments

Comments
 (0)