Skip to content

Commit 641fdf3

Browse files
Merge pull request #587 from anilcanboga/main
translate use server page
2 parents 801f0ab + e15fd4f commit 641fdf3

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed

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

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ canary: true
66

77
<Canary>
88

9-
`'use server'` is needed only if you're [using React Server Components](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) or building a library compatible with them.
9+
`'use server'` sadece [React Sunucu Bileşenlerini kullanıyorsanız](/learn/start-a-new-react-project#bleeding-edge-react-frameworks) veya bunlarla uyumlu bir kütüphane oluşturuyorsanız gereklidir.
1010

1111
</Canary>
1212

1313

1414
<Intro>
1515

16-
`'use server'` marks server-side functions that can be called from client-side code.
16+
`'use server'` istemci tarafı kodundan çağrılabilen sunucu tarafı işlevlerini işaretler.
1717

1818
</Intro>
1919

2020
<InlineToc />
2121

2222
---
2323

24-
## Reference {/*reference*/}
24+
## Başvuru dokümanı {/*reference*/}
2525

2626
### `'use server'` {/*use-server*/}
2727

28-
Add `'use server'` at the top of an async function body to mark the function as callable by the client. We call these functions _Server Actions_.
28+
Fonksiyonu istemci tarafından çağrılabilir olarak işaretlemek için bir asenkron fonksiyon gövdesinin başına `'use server'' ekleyin. Bu işlevlere _Sunucu Eylemleri_ adını veriyoruz.
2929

3030
```js {2}
3131
async function addToCart(data) {
@@ -34,77 +34,76 @@ async function addToCart(data) {
3434
}
3535
```
3636

37-
When calling a Server Action on the client, it will make a network request to the server that includes a serialized copy of any arguments passed. If the Server Action returns a value, that value will be serialized and returned to the client.
37+
İstemcide bir Sunucu Eylemi çağrıldığında, sunucuya iletilen tüm bağımsız değişkenlerin serileştirilmiş bir kopyasını içeren bir ağ isteği gönderilir. Sunucu Eylemi bir değer döndürürse, bu değer serileştirilir ve istemciye döndürülür.
3838

39-
Instead of individually marking functions with `'use server'`, you can add the directive to the top of a file to mark all exports within that file as Server Actions that can be used anywhere, including imported in client code.
39+
İşlevleri tek tek `'use server'` ile işaretlemek yerine, bir dosyanın en üstüne bu yönergeyi ekleyerek o dosyadaki tüm dışa aktarımları, istemci koduna aktarılanlar da dahil olmak üzere her yerde kullanılabilecek Sunucu Eylemleri olarak işaretleyebilirsiniz.
4040

41-
#### Caveats {/*caveats*/}
42-
* `'use server'` must be at the very beginning of their function or module; above any other code including imports (comments above directives are OK). They must be written with single or double quotes, not backticks.
43-
* `'use server'` can only be used in server-side files. The resulting Server Actions can be passed to Client Components through props. See supported [types for serialization](#serializable-parameters-and-return-values).
44-
* To import a Server Action from [client code](/reference/rsc/use-client), the directive must be used on a module level.
45-
* Because the underlying network calls are always asynchronous, `'use server'` can only be used on async functions.
46-
* Always treat arguments to Server Actions as untrusted input and authorize any mutations. See [security considerations](#security).
47-
* Server Actions should be called in a [Transition](/reference/react/useTransition). Server Actions passed to [`<form action>`](/reference/react-dom/components/form#props) or [`formAction`](/reference/react-dom/components/input#props) will automatically be called in a transition.
48-
* Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value.
41+
#### Uyarılar {/*caveats*/}
42+
* `'use server'` fonksiyon veya modüllerinin en başında olmalıdır; içe aktarmalar dahil diğer tüm kodların üzerinde (direktiflerin üzerindeki yorumlar uygundur). Tek ya da çift tırnakla yazılmalıdırlar, ters tırnakla değil.
43+
* `'use server'` sadece sunucu tarafındaki dosyalarda kullanılabilir. Ortaya çıkan Sunucu Eylemleri prop'lar aracılığıyla İstemci Bileşenlerine aktarılabilir. Desteklenen [serileştirme türleri](#serializable-parameters-and-return-values) bölümüne bakın.
44+
* Sunucu Eylemini [istemci kodu](/reference/rsc/use-client)'ndan içe aktarmak için yönerge modül düzeyinde kullanılmalıdır
45+
* Temel ağ çağrıları her zaman asenkron olduğundan, `'use server'` yalnızca asenkron fonksiyonlarda kullanılabilir.
46+
* Sunucu Eylemlerine yönelik bağımsız değişkenleri her zaman güvenilmeyen girdi olarak değerlendirin ve tüm mutasyonları yetkilendirin. Bkz. [güvenlik hususları](#security).
47+
* Sunucu Eylemleri bir [Transition](/reference/react/useTransition) içinde çağrılmalıdır. [`<form action>`](/reference/react-dom/components/form#props) veya [`formAction`](/reference/react-dom/components/input#props)'a geçirilen Sunucu Eylemleri otomatik olarak bir geçişte çağrılacaktır.
48+
* Sunucu Eylemleri sunucu tarafı durumunu güncelleyen mutasyonlar için tasarlanmıştır; veri getirme için önerilmezler. Buna göre, Sunucu Eylemlerini uygulayan çatılar genellikle bir seferde bir eylemi işler ve dönüş değerini önbelleğe almanın bir yolu yoktur.
4949

50-
### Security considerations {/*security*/}
50+
### Güvenlikle ilgili hususlar {/*security*/}
5151

52-
Arguments to Server Actions are fully client-controlled. For security, always treat them as untrusted input, and make sure to validate and escape arguments as appropriate.
52+
Sunucu Eylemlerine yönelik bağımsız değişkenler tamamen istemci kontrolündedir. Güvenlik için bunları her zaman güvenilmeyen girdi olarak ele alın ve bağımsız değişkenleri uygun şekilde doğruladığınızdan ve kaçtığınızdan emin olun.
5353

54-
In any Server Action, make sure to validate that the logged-in user is allowed to perform that action.
54+
Herhangi bir Sunucu Eyleminde, oturum açan kullanıcının bu eylemi gerçekleştirmesine izin verildiğini doğruladığınızdan emin olun.
5555

5656
<Wip>
5757

58-
To prevent sending sensitive data from a Server Action, there are experimental taint APIs to prevent unique values and objects from being passed to client code.
58+
Bir Sunucu Eyleminden hassas verilerin gönderilmesini önlemek için, benzersiz değerlerin ve nesnelerin istemci koduna aktarılmasını önleyen deneysel taint API'leri vardır.
5959

60-
See [experimental_taintUniqueValue](/reference/react/experimental_taintUniqueValue) and [experimental_taintObjectReference](/reference/react/experimental_taintObjectReference).
60+
Bkz. [experimental_taintUniqueValue](/reference/react/experimental_taintUniqueValue) ve [experimental_taintObjectReference](/reference/react/experimental_taintObjectReference).
6161

6262
</Wip>
6363

64-
### Serializable arguments and return values {/*serializable-parameters-and-return-values*/}
64+
### Serileştirilebilir bağımsız değişkenler ve dönüş değerleri {/*serializable-parameters-and-return-values*/}
6565

66-
As client code calls the Server Action over the network, any arguments passed will need to be serializable.
66+
İstemci kodu Sunucu Eylemini ağ üzerinden çağırdığından, aktarılan tüm argümanların serileştirilebilir olması gerekir.
6767

68-
Here are supported types for Server Action arguments:
68+
Sunucu Eylemi bağımsız değişkenleri için desteklenen türler şunlardır:
6969

7070
* Primitives
71-
* [string](https://developer.mozilla.org/en-US/docs/Glossary/String)
72-
* [number](https://developer.mozilla.org/en-US/docs/Glossary/Number)
73-
* [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
74-
* [boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)
75-
* [undefined](https://developer.mozilla.org/en-US/docs/Glossary/Undefined)
76-
* [null](https://developer.mozilla.org/en-US/docs/Glossary/Null)
77-
* [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), only symbols registered in the global Symbol registry via [`Symbol.for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
78-
* Iterables containing serializable values
79-
* [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
80-
* [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
81-
* [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
82-
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
83-
* [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) and [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
71+
* [string](https://developer.mozilla.org/en-US/docs/Glossary/String)
72+
* [number](https://developer.mozilla.org/en-US/docs/Glossary/Number)
73+
* [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
74+
* [boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)
75+
* [undefined](https://developer.mozilla.org/en-US/docs/Glossary/Undefined)
76+
* [null](https://developer.mozilla.org/en-US/docs/Glossary/Null)
77+
* [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol), [`Symbol.for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for) aracılığıyla yalnızca global Sembol kayıt defterine kayıtlı semboller
78+
* Serileştirilebilir değerler içeren yinelenebilir dosyalar
79+
* [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
80+
* [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
81+
* [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
82+
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
83+
* [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) ve [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
8484
* [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
85-
* [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) instances
86-
* Plain [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object): those created with [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer), with serializable properties
87-
* Functions that are Server Actions
85+
* [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) nesne
86+
* Plain [objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object): [object initializers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer) ile oluşturulmuş olanlar, serileştirilebilir özelliklerle
87+
* Sunucu Eylemleri Olan İşlevler
8888
* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
8989

90-
Notably, these are not supported:
91-
* React elements, or [JSX](/learn/writing-markup-with-jsx)
92-
* Functions, including component functions or any other function that is not a Server Action
90+
Özellikle, bunlar desteklenmemektedir:
91+
* React elemanları, ya da [JSX](/learn/writing-markup-with-jsx)
92+
* Bileşen işlevleri veya Sunucu Eylemi olmayan diğer işlevler dahil olmak üzere işlevler
9393
* [Classes](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Classes_in_JavaScript)
94-
* Objects that are instances of any class (other than the built-ins mentioned) or objects with [a null prototype](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects)
95-
* Symbols not registered globally, ex. `Symbol('my new symbol')`
94+
* Herhangi bir sınıfın örneği olan nesneler (belirtilen yerleşikler dışında) veya [null prototipli](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects)
95+
* Global olarak kaydedilmemiş semboller, örn. `Symbol('yeni sembolüm')`
9696

9797

98-
Supported serializable return values are the same as [serializable props](/reference/rsc/use-client#passing-props-from-server-to-client-components) for a boundary Client Component.
98+
Desteklenen serileştirilebilir dönüş değerleri, bir sınır İstemci Bileşeni için [serileştirilebilir proplar](/reference/rsc/use-client#passing-props-from-server-to-client-components) ile aynıdır.
9999

100+
## Kullanım {/*usage*/}
100101

101-
## Usage {/*usage*/}
102+
### Formlarda Sunucu Eylemleri {/*server-actions-in-forms*/}
102103

103-
### Server Actions in forms {/*server-actions-in-forms*/}
104+
Sunucu Eylemlerinin en yaygın kullanım durumu, verileri değiştiren sunucu işlevlerini çağırmak olacaktır. Tarayıcıda, [HTML form elemanı](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) kullanıcının bir mutation göndermesi için geleneksel yaklaşımdır. React Sunucu Bileşenleri ile React, [forms](/reference/react-dom/components/form) Sunucu Eylemleri için birinci sınıf destek sunuyor.
104105

105-
The most common use case of Server Actions will be calling server functions that mutate data. On the browser, the [HTML form element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) is the traditional approach for a user to submit a mutation. With React Server Components, React introduces first-class support for Server Actions in [forms](/reference/react-dom/components/form).
106-
107-
Here is a form that allows a user to request a username.
106+
İşte bir kullanıcının kullanıcı adı talep etmesini sağlayan bir form.
108107

109108
```js [[1, 3, "formData"]]
110109
// App.js
@@ -119,21 +118,21 @@ export default function App() {
119118
return (
120119
<form action={requestUsername}>
121120
<input type="text" name="username" />
122-
<button type="submit">Request</button>
121+
<button type="submit">İstek</button>
123122
</form>
124123
);
125124
}
126125
```
127126

128-
In this example `requestUsername` is a Server Action passed to a `<form>`. When a user submits this form, there is a network request to the server function `requestUsername`. When calling a Server Action in a form, React will supply the form's <CodeStep step={1}>[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)</CodeStep> as the first argument to the Server Action.
127+
Bu örnekte `requestUsername` bir `<form>`a aktarılan bir Sunucu Eylemidir. Bir kullanıcı bu formu gönderdiğinde, `requestUsername` sunucu işlevine bir ağ isteği gönderilir. Bir formda bir Sunucu Eylemi çağırırken, React formun <CodeStep step={1}>[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)</CodeStep> öğesini Sunucu Eylemine ilk argüman olarak sağlayacaktır.
129128

130-
By passing a Server Action to the form `action`, React can [progressively enhance](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement) the form. This means that forms can be submitted before the JavaScript bundle is loaded.
129+
React, `action` formuna bir Sunucu Eylemi geçirerek formu [aşamalı olarak geliştirebilir](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement). Bu, formların JavaScript paketi yüklenmeden önce gönderilebileceği anlamına gelir.
131130

132-
#### Handling return values in forms {/*handling-return-values*/}
131+
#### Formlarda dönüş değerlerini işleme {/*handling-return-values*/}
133132

134-
In the username request form, there might be the chance that a username is not available. `requestUsername` should tell us if it fails or not.
133+
Kullanıcı adı istek formunda, bir kullanıcı adının mevcut olmaması ihtimali olabilir. `requestUsername` bize başarısız olup olmadığını söylemelidir.
135134

136-
To update the UI based on the result of a Server Action while supporting progressive enhancement, use [`useActionState`](/reference/react/useActionState).
135+
Aşamalı geliştirmeyi desteklerken bir Sunucu Eyleminin sonucuna göre kullanıcı arayüzünü güncellemek için [`useActionState`](/reference/react/useActionState) kullanın.
137136

138137
```js
139138
// requestUsername.js
@@ -143,9 +142,9 @@ export default async function requestUsername(formData) {
143142
const username = formData.get('username');
144143
if (canRequest(username)) {
145144
// ...
146-
return 'successful';
145+
return 'başarılı';
147146
}
148-
return 'failed';
147+
return 'başarısız oldu';
149148
}
150149
```
151150

@@ -163,21 +162,22 @@ function UsernameForm() {
163162
<>
164163
<form action={action}>
165164
<input type="text" name="username" />
166-
<button type="submit">Request</button>
165+
<button type="submit">İstek</button>
167166
</form>
168-
<p>Last submission request returned: {state}</p>
167+
<p>Son gönderim talebi iade edildi: {state}</p>
169168
</>
170169
);
171170
}
172171
```
173172

174173
Note that like most Hooks, `useActionState` can only be called in <CodeStep step={1}>[client code](/reference/rsc/use-client)</CodeStep>.
174+
Çoğu Hook gibi `useActionState`in de yalnızca <CodeStep step={1}>[client code](/reference/rsc/use-client)</CodeStep> içinde çağrılabileceğini unutmayın.
175175

176-
### Calling a Server Action outside of `<form>` {/*calling-a-server-action-outside-of-form*/}
176+
### Sunucu Eylemini `<form>` dışında çağırma {/*calling-a-server-action-outside-of-form*/}
177177

178-
Server Actions are exposed server endpoints and can be called anywhere in client code.
178+
Sunucu Eylemleri açık sunucu uç noktalarıdır ve istemci kodunun herhangi bir yerinde çağrılabilir.
179179

180-
When using a Server Action outside of a [form](/reference/react-dom/components/form), call the Server Action in a [Transition](/reference/react/useTransition), which allows you to display a loading indicator, show [optimistic state updates](/reference/react/useOptimistic), and handle unexpected errors. Forms will automatically wrap Server Actions in transitions.
180+
[Form](/reference/react-dom/components/form) dışında bir Sunucu Eylemi kullanırken, Sunucu Eylemini bir [Transition](/reference/react/useTransition) içinde çağırın; bu sayede bir yükleme göstergesi görüntüleyebilir, [iyimser state güncellemeleri](/reference/react/useOptimistic) gösterebilir ve beklenmedik hataları ele alabilirsiniz
181181

182182
```js {9-12}
183183
import incrementLike from './actions';
@@ -196,8 +196,8 @@ function LikeButton() {
196196

197197
return (
198198
<>
199-
<p>Total Likes: {likeCount}</p>
200-
<button onClick={onClick} disabled={isPending}>Like</button>;
199+
<p>Toplam Beğeni: {likeCount}</p>
200+
<button onClick={onClick} disabled={isPending}>Beğen</button>;
201201
</>
202202
);
203203
}
@@ -214,4 +214,4 @@ export default async function incrementLike() {
214214
}
215215
```
216216

217-
To read a Server Action return value, you'll need to `await` the promise returned.
217+
Bir Sunucu Eylemi dönüş değerini okumak için, döndürülen promise'i `await` etmeniz gerekir.

0 commit comments

Comments
 (0)