import filename Last updated: 31. Jul 2026
API only function
Keyword
The import keyword in JavaScript is used to import functions, objects, or variables from another file, which can then be used in the current file.
Parameters
| Name | Type | Description |
|---|---|---|
| filename | string | Absolute path to file to include. |
Returns
Nothing is returned. The imported bindings (functions, objects or values) are made available in the current scope.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// Named import - bring specific exports into scope
import { formatPrice } from "#/helpers.js";
// Namespace import - bring everything in under one object
import * as helpers from "#/helpers.js";
// Default import - the module's primary export
import config from "#/config.js";
// Use them inside an API function
export default () => {
return {
price: formatPrice(199),
total: helpers.sum([10, 20, 30]),
currency: config.currency
};
}