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
Copy file name to clipboardExpand all lines: src/content/reference/rsc/server-components.md
+58-58Lines changed: 58 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -5,36 +5,36 @@ canary: true
5
5
6
6
<Intro>
7
7
8
-
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.
8
+
Sunucu Bileşenleri, önceden, paketlemeden önce, istemci uygulamanızdan veya SSR sunucusundan ayrı bir ortamda render edilen yeni bir Bileşen türüdür.
9
9
10
10
</Intro>
11
11
12
-
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.
12
+
Bu ayrı ortam, React Sunucu Bileşenlerinde "sunucu" olarak adlandırılır. Sunucu Bileşenleri, CI sunucunuzda build zamanı sırasında bir kez çalışabilir veya her istekte bir web sunucusu kullanılarak çalıştırılabilir.
13
13
14
14
<InlineToc />
15
15
16
16
<Note>
17
17
18
-
#### How do I build support for Server Components? {/*how-do-i-build-support-for-server-components*/}
18
+
#### Sunucu Bileşenleri için nasıl destek oluşturulur? {/*how-do-i-build-support-for-server-components*/}
19
19
20
-
While React Server Components in React 19 are stable and will not break between major 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.
20
+
React 19'daki React Sunucu Bileşenleri kararlıdır ve büyük sürümler arasında bozulmaz, ancak bir React Sunucu Bileşenleri paketleyicisi veya çatısı uygulamak için kullanılan temel API'ler semver'i takip etmez ve React 19.x sürümleri arasında minor sürümlerde bozulabilir.
21
21
22
-
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.
22
+
React Sunucu Bileşenleri'ni bir paketleyici veya çatı olarak desteklemek için, belirli bir React sürümüne sabitlemenizi veya Canary sürümünü kullanmanızı öneririz. Gelecekte, React Sunucu Bileşenleri'ni uygulamak için kullanılan API'leri stabilize etmek amacıyla paketleyiciler ve çatılarla çalışmaya devam edeceğiz.
23
23
24
24
</Note>
25
25
26
-
### Server Components without a Server {/*server-components-without-a-server*/}
27
-
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.
26
+
### Sunucu Olmadan Sunucu Bileşenleri {/*server-components-without-a-server*/}
27
+
Sunucu bileşenleri, dosya sisteminden okumak veya statik içerik almak için build zamanı sırasında çalışabilir, bu nedenle bir web sunucusu gerekmez. Örneğin, bir içerik yönetim sisteminden statik veriler okumak isteyebilirsiniz.
28
28
29
-
Without Server Components, it's common to fetch static data on the client with an Effect:
29
+
Sunucu Bileşenleri olmadan, statik verileri istemcide bir Efekt ile almak yaygındır:
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.
56
+
Bu desen, kullanıcıların ek olarak 75K (gzipped) kütüphane indirip çözümlemeleri gerektiği ve sayfa yüklendikten sonra verileri almak için ikinci bir isteği beklemeleri gerektiği anlamına gelir; sadece sayfa ömrü boyunca değişmeyecek statik içeriği render etmek için.
57
57
58
-
With Server Components, you can render these components once at build time:
58
+
Sunucu Bileşenleri ile, bu bileşenleri build zamanı sırasında bir kez render edebilirsiniz:
59
59
60
60
```js
61
-
importmarkedfrom'marked'; //Not included in bundle
62
-
importsanitizeHtmlfrom'sanitize-html'; //Not included in bundle
61
+
importmarkedfrom'marked'; //Paket içinde dahil edilmemiş
62
+
importsanitizeHtmlfrom'sanitize-html'; //Paket içinde dahil edilmemiş
63
63
64
64
asyncfunctionPage({page}) {
65
-
//NOTE: loads *during* render, when the app is built.
65
+
//NOT: Render sırasında, uygulama build edilirken yüklenir.
66
66
constcontent=awaitfile.readFile(`${page}.md`);
67
67
68
68
return<div>{sanitizeHtml(marked(content))}</div>;
69
69
}
70
70
```
71
71
72
-
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:
72
+
Render edilen çıktı daha sonra sunucu tarafında render edilip (SSR) HTML olarak oluşturulabilir ve bir CDN'ye yüklenebilir. Uygulama yüklendiğinde, istemci orijinal `Page`bileşenini veya markdown render'lamak için kullanılan pahalı kütüphaneleri görmez. İstemci yalnızca render edilmiş çıktıyı görür:
73
73
74
74
```js
75
-
<div><!--html for markdown--></div>
75
+
<div><!--markdown için html--></div>
76
76
```
77
77
78
-
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.
78
+
Bu, içeriğin ilk sayfa yüklemesi sırasında görünür olduğu ve paketlemenin statik içeriği render etmek için gereken pahalı kütüphaneleri içermediği anlamına gelir.
79
79
80
80
<Note>
81
81
82
-
You may notice that the Server Component above is an async function:
82
+
Yukarıdaki Sunucu Bileşeni'nin bir async fonksiyon olduğunu fark etmiş olabilirsiniz:
83
83
84
84
```js
85
85
asyncfunctionPage({page}) {
86
86
//...
87
87
}
88
88
```
89
89
90
-
Async Components are a new feature of Server Components that allow you to `await` in render.
90
+
Async Bileşenleri, render sırasında `await` yapmanıza olanak tanıyan Sunucu Bileşenleri'nin yeni bir özelliğidir.
91
91
92
-
See [Async components with Server Components](#async-components-with-server-components)below.
92
+
Aşağıda [Sunucu Bileşenleri ile Async Bileşenleri](#async-components-with-server-components)başlığına bakın.
93
93
94
94
</Note>
95
95
96
-
### Server Components with a Server {/*server-components-with-a-server*/}
97
-
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.
96
+
### Sunucu ile Sunucu Bileşenleri {/*server-components-with-a-server*/}
97
+
Sunucu Bileşenleri, bir sayfa isteği sırasında bir web sunucusunda da çalışabilir, böylece bir API oluşturmanıza gerek kalmadan veri katmanınıza erişmenizi sağlar. Uygulamanız paketlenmeden önce render edilirler ve veri ile JSX'i İstemci Bileşenlerine prop olarak geçirebilirler.
98
98
99
-
Without Server Components, it's common to fetch dynamic data on the client in an Effect:
99
+
Sunucu Bileşenleri olmadan, dinamik verileri istemcide bir Efekt ile almak yaygındır:
100
100
101
101
```js
102
102
// bundle.js
103
103
functionNote({id}) {
104
104
const [note, setNote] =useState('');
105
-
//NOTE: loads *after* first render.
105
+
//NOT: İlk render'dan *sonra* yüklenir.
106
106
useEffect(() => {
107
107
fetch(`/api/notes/${id}`).then(data=> {
108
108
setNote(data.note);
@@ -119,8 +119,8 @@ function Note({id}) {
119
119
120
120
functionAuthor({id}) {
121
121
const [author, setAuthor] =useState('');
122
-
//NOTE: loads *after* Note renders.
123
-
//Causing an expensive client-server waterfall.
122
+
//NOT: Note render'ı *sonra* yüklenir.
123
+
//Pahalı bir istemci-sunucu şelalesine neden olur.
With Server Components, you can read the data and render it in the component:
148
+
Sunucu Bileşenleri ile veriyi okuyabilir ve bileşende render edebilirsiniz:
149
149
150
150
```js
151
151
importdbfrom'./database';
152
152
153
153
asyncfunctionNote({id}) {
154
-
//NOTE: loads *during* render.
154
+
//NOT: Render sırasında *yüklenir.
155
155
constnote=awaitdb.notes.get(id);
156
156
return (
157
157
<div>
@@ -162,42 +162,42 @@ async function Note({id}) {
162
162
}
163
163
164
164
asyncfunctionAuthor({id}) {
165
-
//NOTE: loads *after* Note,
166
-
//but is fast if data is co-located.
165
+
//NOT: Note'dan *sonra* yüklenir,
166
+
//ancak veri aynı konumda ise hızlıdır.
167
167
constauthor=awaitdb.authors.get(id);
168
168
return<span>By: {author.name}</span>;
169
169
}
170
170
```
171
171
172
-
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:
172
+
Paketleyici, ardından veriyi, render edilen Sunucu Bileşenlerini ve dinamik İstemci Bileşenlerini bir pakette birleştirir. İsteğe bağlı olarak, bu paket daha sonra sunucu tarafında render edilip (SSR) sayfanın ilk HTML'ini oluşturabilir. Sayfa yüklendiğinde, tarayıcı orijinal `Note`ve`Author`bileşenlerini görmez; yalnızca render edilmiş çıktı istemciye gönderilir:
173
173
174
174
```js
175
175
<div>
176
-
<span>By: The React Team</span>
177
-
<p>React 19 is...</p>
176
+
<span>Yazan:React Ekibi</span>
177
+
<p>React 19...</p>
178
178
</div>
179
179
```
180
180
181
-
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.
181
+
Sunucu Bileşenleri, sunucudan tekrar alınıp veriye erişip yeniden render edilerek dinamik hale getirilebilir. Bu yeni uygulama mimarisi, sunucu odaklı Çok Sayfalı Uygulamalar'ın basit “istek/cevap” zihniyet modelini, istemci odaklı Tek Sayfa Uygulamalarının sorunsuz etkileşimiyle birleştirir ve size her iki dünyanın da en iyisini sunar.
182
182
183
-
### Adding interactivity to Server Components {/*adding-interactivity-to-server-components*/}
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.
185
+
Sunucu Bileşenleri tarayıcıya gönderilmez, bu yüzden `useState` gibi etkileşimli API'leri kullanamazlar. Sunucu Bileşenlerine etkileşim eklemek için, bunları `"use client"`yönergesini kullanarak İstemci Bileşeni ile birleştirebilirsiniz.
186
186
187
187
<Note>
188
188
189
-
#### There is no directive for Server Components. {/*there-is-no-directive-for-server-components*/}
189
+
#### Sunucu Bileşenleri için bir yönerge yoktur. {/*there-is-no-directive-for-server-components*/}
190
190
191
-
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 Actions.
191
+
Yaygın bir yanlış anlama, Sunucu Bileşenlerinin `"use server"` ile belirtildiğidir, ancak Sunucu Bileşenleri için bir yönerge yoktur. `"use server"`yönergesi, Sunucu İşlemleri (Server Actions) için kullanılır.
192
192
193
-
For more info, see the docs for [Directives](/reference/rsc/directives).
193
+
Daha fazla bilgi için, [Yönergeler](/reference/rsc/directives) dökümantasyonuna bakın.
194
194
195
195
</Note>
196
196
197
197
198
-
In the following example, the `Notes`Server Component imports an `Expandable` Client Component that uses state to toggle its `expanded` state:
198
+
Aşağıdaki örnekte, `Notes`Sunucu Bileşeni, `expanded` state'ini değiştirmek için state kullanan bir `Expandable` İstemci Bileşenini içe aktarır:
199
199
```js
200
-
//Server Component
200
+
//Sunucu Bileşeni
201
201
importExpandablefrom'./Expandable';
202
202
203
203
asyncfunctionNotes() {
@@ -214,7 +214,7 @@ async function Notes() {
214
214
}
215
215
```
216
216
```js
217
-
//Client Component
217
+
//İstemci Bileşeni
218
218
"use client"
219
219
220
220
exportdefaultfunctionExpandable({children}) {
@@ -232,46 +232,46 @@ export default function Expandable({children}) {
232
232
}
233
233
```
234
234
235
-
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:
235
+
Bu, önce `Notes`'u bir Sunucu Bileşeni olarak render edip, ardından paketleyiciye `Expandable` İstemci Bileşeni için bir paket oluşturması talimatı vererek çalışır. Tarayıcıda, İstemci Bileşenleri, prop olarak geçirilen Sunucu Bileşenlerinin çıktısını görecektir:
236
236
237
237
```js
238
238
<head>
239
-
<!--the bundle for Client Components-->
239
+
<!--İstemci Bileşenleri için paket-->
240
240
<script src="bundle.js"/>
241
241
</head>
242
242
<body>
243
243
<div>
244
244
<Expandable key={1}>
245
-
<p>this is the first note</p>
245
+
<p>bu ilk nottur</p>
246
246
</Expandable>
247
247
<Expandable key={2}>
248
-
<p>this is the second note</p>
248
+
<p>bu ikinci nottur</p>
249
249
</Expandable>
250
250
<!--...-->
251
251
</div>
252
252
</body>
253
253
```
254
254
255
-
### Async components with Server Components {/*async-components-with-server-components*/}
255
+
### Sunucu Bileşenleri ile Async Bileşenleri {/*async-components-with-server-components*/}
256
256
257
-
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.
257
+
Sunucu Bileşenleri, async/await kullanarak Bileşen yazmanın yeni bir yolunu tanıtır. Bir async bileşen içinde`await`kullandığınızda, React render'lamaya devam etmeden önce promise'in çözülmesini bekler. Bu, sunucu/istemci sınırlarında, Suspense için stream desteğiyle çalışır.
258
258
259
-
You can even create a promise on the server, and await it on the client:
259
+
Hatta sunucuda bir promise oluşturabilir ve bunu istemcide bekleyebilirsiniz:
260
260
261
261
```js
262
-
//Server Component
262
+
//Sunucu Bileşeni
263
263
importdbfrom'./database';
264
264
265
265
asyncfunctionPage({id}) {
266
-
//Will suspend the Server Component.
266
+
//Sunucu Bileşenini askıya alır.
267
267
constnote=awaitdb.notes.get(id);
268
268
269
-
//NOTE: not awaited, will start here and await on the client.
269
+
//NOT: beklenmemiş, burada başlayacak ve istemcide bekleyecek.
//NOTE: this will resume the promise from the server.
289
-
//It will suspend until the data is available.
288
+
//NOT: Bu, sunucudan gelen promise'i yeniden başlatacak.
289
+
//Veriler mevcut olana kadar askıya alınacak.
290
290
constcomments=use(commentsPromise);
291
291
returncomments.map(commment=><p>{comment}</p>);
292
292
}
293
293
```
294
294
295
-
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.
295
+
`note`içeriği, sayfanın render edilmesi için önemli bir veri olduğu için, sunucuda `await`edilir. Yorumlar ise daha aşağıda ve önceliği düşük olduğundan, promise'i sunucuda başlatırız ve istemcide `use` API'si ile bekleriz. Bu, istemcide askıya alınacak, ancak `note`içeriğinin render edilmesini engellemeyecektir.
296
296
297
-
Since async components are [not supported on the client](#why-cant-i-use-async-components-on-the-client), we await the promise with `use`.
297
+
Async bileşenler [istemcide desteklenmediği için](#why-cant-i-use-async-components-on-the-client), promise'i `use` ile bekleriz.
0 commit comments