Edge Runtime
Next.js Edge Runtime standart Web API'lerini temel alır, aşağıdaki API'leri destekler:
Network APIs
API | Description |
---|---|
Blob | Represents a blob |
fetch | Fetches a resource |
FetchEvent | Represents a fetch event |
File | Represents a file |
FormData | Represents form data |
Headers | Represents HTTP headers |
Request | Represents an HTTP request |
Response | Represents an HTTP response |
URLSearchParams | Represents URL search parameters |
WebSocket | Represents a websocket connection |
Encoding APIs
API | Description |
---|---|
atob | Decodes a base-64 encoded string |
btoa | Encodes a string in base-64 |
TextDecoder | Decodes a Uint8Array into a string |
TextDecoderStream | Chainable decoder for streams |
TextEncoder | Encodes a string into a Uint8Array |
TextEncoderStream | Chainable encoder for streams |
Stream APIs
API | Description |
---|---|
ReadableStream | Represents a readable stream |
ReadableStreamBYOBReader | Represents a reader of a ReadableStream |
ReadableStreamDefaultReader | Represents a reader of a ReadableStream |
TransformStream | Represents a transform stream |
WritableStream | Represents a writable stream |
WritableStreamDefaultWriter | Represents a writer of a WritableStream |
Crypto APIs
API | Description |
---|---|
crypto | Provides access to the cryptographic functionality of the platform |
CryptoKey | Represents a cryptographic key |
SubtleCrypto | Provides access to common cryptographic primitives, like hashing, signing, encryption or decryption |
Web Standard APIs
API | Description |
---|---|
AbortController | Allows you to abort one or more DOM requests as and when desired |
Array | Represents an array of values |
ArrayBuffer | Represents a generic, fixed-length raw binary data buffer |
Atomics | Provides atomic operations as static methods |
BigInt | Represents a whole number with arbitrary precision |
BigInt64Array | Represents a typed array of 64-bit signed integers |
BigUint64Array | Represents a typed array of 64-bit unsigned integers |
Boolean | Represents a logical entity and can have two values: true and false |
clearInterval | Cancels a timed, repeating action which was previously established by a call to setInterval() |
clearTimeout | Cancels a timed, repeating action which was previously established by a call to setTimeout() |
console | Provides access to the browser's debugging console |
DataView | Represents a generic view of an ArrayBuffer |
Date | Represents a single moment in time in a platform-independent format |
decodeURI | Decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine |
decodeURIComponent | Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine |
DOMException | Represents an error that occurs in the DOM |
encodeURI | Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character |
encodeURIComponent | Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character |
Error | Represents an error when trying to execute a statement or accessing a property |
EvalError | Represents an error that occurs regarding the global function eval() |
Float32Array | Represents a typed array of 32-bit floating point numbers |
Float64Array | Represents a typed array of 64-bit floating point numbers |
Function | Represents a function |
Infinity | Represents the mathematical Infinity value |
Int8Array | Represents a typed array of 8-bit signed integers |
Int16Array | Represents a typed array of 16-bit signed integers |
Int32Array | Represents a typed array of 32-bit signed integers |
Intl | Provides access to internationalization and localization functionality |
isFinite | Determines whether a value is a finite number |
isNaN | Determines whether a value is NaN or not |
JSON | Provides functionality to convert JavaScript values to and from the JSON format |
Map | Represents a collection of values, where each value may occur only once |
Math | Provides access to mathematical functions and constants |
Number | Represents a numeric value |
Object | Represents the object that is the base of all JavaScript objects |
parseFloat | Parses a string argument and returns a floating point number |
parseInt | Parses a string argument and returns an integer of the specified radix |
Promise | Represents the eventual completion (or failure) of an asynchronous operation, and its resulting value |
Proxy | Represents an object that is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc) |
queueMicrotask | Queues a microtask to be executed |
RangeError | Represents an error when a value is not in the set or range of allowed values |
ReferenceError | Represents an error when a non-existent variable is referenced |
Reflect | Provides methods for interceptable JavaScript operations |
RegExp | Represents a regular expression, allowing you to match combinations of characters |
Set | Represents a collection of values, where each value may occur only once |
setInterval | Repeatedly calls a function, with a fixed time delay between each call |
setTimeout | Calls a function or evaluates an expression after a specified number of milliseconds |
SharedArrayBuffer | Represents a generic, fixed-length raw binary data buffer |
String | Represents a sequence of characters |
structuredClone | Creates a deep copy of a value |
Symbol | Represents a unique and immutable data type that is used as the key of an object property |
SyntaxError | Represents an error when trying to interpret syntactically invalid code |
TypeError | Represents an error when a value is not of the expected type |
Uint8Array | Represents a typed array of 8-bit unsigned integers |
Uint8ClampedArray | Represents a typed array of 8-bit unsigned integers clamped to 0-255 |
Uint32Array | Represents a typed array of 32-bit unsigned integers |
URIError | Represents an error when a global URI handling function was used in a wrong way |
URL | Represents an object providing static methods used for creating object URLs |
URLPattern | Represents a URL pattern |
URLSearchParams | Represents a collection of key/value pairs |
WeakMap | Represents a collection of key/value pairs in which the keys are weakly referenced |
WeakSet | Represents a collection of objects in which each object may occur only once |
WebAssembly | Provides access to WebAssembly |
Next.js Specific Polyfills
Environment Variables
Hem next dev
hem de next build
için Ortam Değişkenlerine erişmek için process.env
adresini kullanabilirsiniz.
Unsupported APIs
Edge Runtime'ın aşağıdakiler dahil bazı kısıtlamaları vardır:
- Yerel Node.js API'leri desteklenmez. Örneğin, dosya sistemini okuyamaz veya dosya sistemine yazamazsınız.
node_modules
ES Modüllerini uyguladıkları ve yerel Node.js API'lerini kullanmadıkları sürece kullanılabilir .require
adresinin doğrudan çağrılmasına izin verilmez. Bunun yerine ES Modüllerini kullanın.
Aşağıdaki JavaScript dili özellikleri devre dışı bırakılmıştır ve çalışmayacaktır:
API | Description |
---|---|
eval | Evaluates JavaScript code represented as a string |
new Function(evalString) | Creates a new function with the code provided as an argument |
WebAssembly.compile | Compiles a WebAssembly module from a buffer source |
WebAssembly.instantiate | Compiles and instantiates a WebAssembly module from a buffer source |
Nadir durumlarda, kodunuz çalışma zamanında erişilemeyen ve ağaç sallama ile kaldırılamayan bazı dinamik kod değerlendirme deyimleri içerebilir (veya içe aktarılabilir). Middleware veya Edge API Route dışa aktarılan yapılandırmanızla belirli dosyalara izin vermek için denetimi gevşetebilirsiniz:
export const config = {
runtime: 'edge', // for Edge API Routes only
unstable_allowDynamic: [
// allows a single file
'/lib/utilities.js',
// use a glob to allow anything in the function-bind 3rd party module
'/node_modules/function-bind/**',
],
}
unstable_allowDynamic
bir glob veya belirli dosyalar için dinamik kod değerlendirmesini yok sayan bir glob dizisidir. Globlar uygulamanızın kök klasörüne görelidir.
Bu ifadeler Edge üzerinde çalıştırılırsa, çalışma zamanı hatasına neden olacakları konusunda uyarılmalıdır.