JavaScript export Statement
The export declaration makes values, functions and classes from a JavaScript module available for other modules to import.
Description
The export declaration marks values to be shared from a module. A module can have any number of named exports, imported by their names in braces, and at most one default export, imported with any name you choose. You can export declarations directly, export a list of existing names (renaming with as), or re-export from another module with export ... from.
Exports are live bindings: if the exporting module changes an exported let variable, importers see the new value. export can only be used in modules.
Named exports are usually preferred, because the name is fixed, which makes searching and automatic refactoring easier, and a module can export several things. A default export suits modules that provide one main thing, such as a class or a component. A module can have both. Re-exporting with export * from is a common way to create a single entry point, often called a barrel file, that gathers the exports of several modules.
Syntax
export const name = value;
export function fn() {}
export default expression;
export { name1, name2 as alias };
export * from './other.js';Example
Browser Support
The following information will show you the current browser support for the export statement. Hover over a browser icon to see the version that first introduced support for this statement.
Desktop





Tablets & Mobile





