Sass meta.get-module()

Intermediate
9 min read
Updated: Nov 2026
5 examples
Dart Sass 1.105+

Definition and Usage

meta.get-module($name) returns the module value for a module you already loaded with @use. $name is the namespace—the last part of the URL, or the alias you chose with as.

Load it with @use "sass:meta". Requires Dart Sass 1.105+.

Namespace, not URL.

Pass "theme" for @use "theme", or "t" for @use "theme" as t. For built-ins, use the namespace such as "math", not "sass:math".

Not loading anything.

meta.get-module() never loads a file. For that, use meta.load().

Unknown namespace = error.

If no module with that namespace exists in the current file, Sass stops with “There is no module with namespace…”.

Syntax

SCSS
@use "sass:meta";
@use "theme";
@use "other" as o;
@use "sass:math";

meta.get-module($name); //=> module

$theme: meta.get-module("theme");
$other: meta.get-module("o");
$math:  meta.get-module("math");

meta.module-variables($theme);          // map of variables
meta.get-function("rem", $module: $theme);

// Module API — Dart Sass 1.105+

Pattern: @use a module → meta.get-module("namespace") → pass the value to other meta functions.

Which Name to Pass

The $name must match a namespace in the current file:

Rule$nameWorks?
@use "theme""theme"Yes
@use "theme" as t"t"Yes
@use "sass:math""math"Yes
@use "sass:math""sass:math"No—error
Never loaded"nope"No—error
Need to load first?

If the stylesheet is not loaded yet, call meta.load() instead.

SCSS Examples

Examples target Dart Sass 1.105+ with @use "sass:meta". Helper files are shown above each main file. Open View Compiled CSS to see the result.

Example 1 — Turn a Namespace into a Module

Fetch the module for @use "theme".

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:meta";
@use "theme";

$module: meta.get-module("theme");

.info {
  --type: #{meta.type-of($module)};
  --inspect: #{meta.inspect($module)};
}

How It Works

  1. @use "theme" loads the file and creates the namespace theme.
  2. meta.get-module("theme") returns its module value.
  3. meta.type-of reports module.
  4. .theme appears once because of @use, not because of get-module.

Example 2 — Use the Alias, Not the URL

With as t, the namespace is t.

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:map";
@use "sass:meta";
@use "theme" as t;

$module: meta.get-module("t");

.card {
  color: map.get(meta.module-variables($module), "primary");
}

How It Works

  1. as t renames the namespace to t.
  2. meta.get-module("t") uses that alias.
  3. meta.module-variables reads the variable map from the module.
  4. map.get returns #036.

Example 3 — Fetch a Built-In Module

Built-ins are modules too—use their namespace.

SCSS
@use "sass:map";
@use "sass:math";
@use "sass:meta";

$math: meta.get-module("math");

.constants {
  --type: #{meta.type-of($math)};
  --pi: #{map.get(meta.module-variables($math), "pi")};
}

How It Works

  1. @use "sass:math" creates the namespace math.
  2. meta.get-module("math") returns the built-in module.
  3. module-variables exposes constants like pi.
  4. See math constants.

Example 4 — List Functions, Mixins, and Variables

The same module value works with every module-* function.

SCSS
@use "sass:math";

$primary: #036 !default;

@function rem($px) {
  @return math.div($px, 16px) * 1rem;
}

@mixin stretch {
  display: flex;
  flex: 1;
}
SCSS
@use "sass:map";
@use "sass:meta";
@use "theme";

$module: meta.get-module("theme");

.info {
  --functions: #{meta.inspect(meta.module-functions($module))};
  --mixins: #{meta.inspect(meta.module-mixins($module))};
  --variables: #{meta.inspect(meta.module-variables($module))};
  font-size: meta.call(map.get(meta.module-functions($module), "rem"), 32px);
}

How It Works

  1. One module value feeds all three module-* functions.
  2. Maps contain function and mixin values, printed as get-function(...) / get-mixin(...).
  3. meta.call runs the rem function from the map.
  4. Result: 32px becomes 2rem.

Example 5 — Unknown Namespace Fails

Asking for a module that was never loaded is an error.

SCSS
$primary: #036 !default;
$radius: 4px !default;

.theme {
  color: $primary;
}
SCSS
@use "sass:meta";
@use "theme";

$module: meta.get-module("nope");

How It Works

  1. nope is not a namespace in this file.
  2. meta.get-module does not search for stylesheets.
  3. Sass stops with a clear error and caret.
  4. Fix: @use the module first, or call meta.load().

Edge Cases & Pitfalls

Most get-module errors are using the wrong namespace or expecting it to load files.

alias

Use the alias after as

If you wrote @use "theme" as t, the namespace is t and "theme" will fail.

builtin

Built-ins use short names

Use "math", not "sass:math".

load

get-module never loads

It only finds modules already loaded in this file. Use meta.load() to load by URL.

scope

Namespaces are per file

A module loaded by another stylesheet is not visible by namespace here unless you @use it.

Sass Support

Part of the first-class module support in recent Dart Sass.

APIStatus
meta.get-module()Dart Sass 1.105+ via @use "sass:meta"
InputString matching a @use namespace
Return typeModule value
LibSass / Ruby SassNot supported

Compile with the Dart Sass CLI.

Key Takeaways

  • Returns the module value for a @use namespace.
  • Alias counts: as t means meta.get-module("t").
  • Built-ins work with names like "math".
  • Does not load—use meta.load() for that.

One line: call meta.get-module("namespace") when you need a loaded module as a value.

Compile Notes

Practical checklist:

checklist.txt
1. @use "sass:meta"
2. @use the module first
3. Pass the namespace (or alias), not the URL
4. Use the value as $module in other meta functions
5. Use meta.load() when the file is not loaded yet

Frequently Asked Questions

meta.get-module($name) returns the module value for a module already loaded in the current file, looked up by its namespace.
The namespace: "theme" for @use "theme", the alias for @use "theme" as t, and "math" for @use "sass:math". The full sass: URL does not work.
No. It only finds modules already loaded with @use. Use meta.load() to load a stylesheet by URL.
Sass stops with an error saying there is no module with that namespace.
Pass it as $module to meta.get-function(), meta.get-mixin(), meta.module-variables(), meta.module-functions(), or meta.module-mixins().
Dart Sass 1.105 and later. LibSass and Ruby Sass do not provide first-class modules.

Next: Sass meta.module-functions()

List every function defined in a module.

meta.module-functions() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful