Using await at the top level in ES modules

June 20, 2025

""

Writing asynchronous code in JavaScript used to come with a limitation: the await keyword could only be used inside an async function. That changed when ES2022 introduced top-level await: a modern ES module feature that enables new patterns for asynchronous code at the module level.

Source: Using await at the top level in ES modules – Matt Smith

An overview of the relatively new top level await femur of ES Modules.