When should I use curly braces for ES6 import?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In ES modules, curly braces in an import statement mean you are importing a named export. If the module exported a default value, you import it without braces.
That simple rule covers most cases, but developers still trip over it because a module can export both kinds at once, and the import syntax changes depending on which one you want.
The Core Rule
Use curly braces when the thing being imported was exported by name:
Do not use curly braces for a default export:
That is the main distinction.
Named Exports Use the Exact Exported Name
Named imports must match the exported identifier unless you rename them with as.
You can rename a named import like this:
Curly braces are still required because the import is still a named export, just aliased locally.
Default Exports Do Not Use Braces
A default export can be imported with any local name you choose:
The name theme is chosen by the importer. It does not have to match a name in the source module.
Modules Can Have Both
A module can export one default value and also export named values:
Then the import combines both forms:
The default import comes first, and the named imports stay inside braces.
Namespace Imports Are Different Again
There is also the namespace form:
This does not use curly braces because it is not importing one named export directly. It is importing the module namespace object.
A Practical Way to Decide
When reading a module, ask how the export was declared:
- '
export default ...means import without braces' - '
export const ...,export function ..., orexport class ...means import with braces' - '
export defaultplus named exports means combine both forms'
If the module documentation shows import React from "react", that is a default import. If it shows import { useState } from "react", useState is a named export.
Common Pitfalls
The most common mistake is using braces around a default export:
That fails because log was exported as default, not as a named binding.
Another common mistake is dropping braces around a named export:
That asks for the default export, but math.js only exported named values.
Developers also get confused when bundlers or transpilers show slightly different error messages. The underlying rule is still the same: match the import syntax to the export type.
Finally, remember that CommonJS modules do not always map cleanly to ES module syntax. If you are mixing module systems, read the package documentation instead of guessing from the filename alone.
Summary
- Use curly braces for named exports.
- Do not use curly braces for default exports.
- A module can have one default export and many named exports.
- Use
asto rename a named import without changing the need for braces. - If the import keeps failing, check whether the source module exported a default value or a named one.

