Favorites

JavaScript async function* Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
async function*
JavaScript Functions and ClassesThis statement is supported by all modern browsers.
Updated 28th November 2026

An async generator function combines async and function*: it can await promises and yield values over time, and is consumed with for await...of.

Description

The async function* declaration defines an async generator. It can use both await and yield, and returns an async iterator whose next() method returns promises. It suits data that arrives over time, such as pages of results from an API or chunks from a stream, and is usually consumed with for await...of.

Inside an async generator, await waits for a promise as usual, and yield hands a value to whoever is iterating. Each call to the iterator's next() returns a promise for { value, done }, so consumers naturally wait for each value to be ready. Requests to next() made before the previous one finishes are queued, so values always arrive in order.

They're ideal for wrapping APIs that deliver data in pieces: paginated endpoints, streamed responses, WebSocket messages or file reading. The consumer can stop early with break, which runs any finally block in the generator so it can release its resources.

Syntax

async function* name(params) {
  yield await value;
}

Example

async function* pages(total) {
  for (let page = 1; page <= total; page++) {
    await new Promise(r => setTimeout(r, 100));
    yield [`item ${page}a`, `item ${page}b`];
  }
}

(async () => {
  for await (const items of pages(3)) console.log(items);
})();

Browser Support

The following information will show you the current browser support for the async function* statement. Hover over a browser icon to see the version that first introduced support for this statement.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee