# Frequently Asked Questions

Answers to common questions about building with Embeddable. Select a question to see its answer.

## How Do I Configure User Facing Datasets to Include or Exclude Joined Tables?

By default, if your data model includes joined tables, and you make that data model available to users, the data they have access to will **also include those joined tables**. This can be desirable, depending on the data, but there may be times when you only want users to be able to access the data from the primary model, and not from any joined tables.

In this case, you can use [Cube Views](https://docs.embeddable.com/data-modeling/writing-data-models/views) to gain **fine-grained control** over what data from a particular table or set of tables is available to your users. This will allow you to restrict access (or grant it) as you prefer.

## Are Cancelled Queries on Dashboard Load Normal?

When your dashboards are loading, sometimes you might see cancelled queries in the network tab, like so:

![Screenshot 2026-03-26 at 19.25.55|620x224](https://docs.embeddable.com/img/faq/f9551210e69c3ca5ecae7764cc5af3783662a2af.png)

This happens when a component immediately updates variable values after they are rendered and is nothing to worry about ☺️ If you have any concerns please drop our team a message.

## How Do I Use Tailwind CSS Inside Embeddable Custom Components (Remarkable)?

Tailwind utility classes don’t apply consistently inside Embeddable components because the embedded experience runs inside a **shadow DOM**, which blocks external stylesheets from penetrating the component scope. CSS variables do pass through the shadow DOM boundary, but class-based styles do not.

You don’t need to abandon Tailwind — here’s how to make it work.

#### Step 1: Add a Tailwind config to your boilerplate repo

Create a `tailwind.config.js` at the top level of your boilerplate repo. At minimum it should look like this:

```js
/** @type {import('tailwindcss').Config} */
module.exports = {
  darkMode: 'class',
  content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
  theme: {
    extend: {},
  },
  plugins: [],
};
```

#### Step 2: Add an index.css to your components folder

Create a `src/components/index.css` (or equivalent) that begins with:

```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```

This injects the necessary Tailwind styles so your classes resolve correctly at runtime.

#### Arbitrary values won’t work — extend the config instead

Embeddable doesn’t support Tailwind arbitrary values like `border-[#888888]`. Instead, extend your Tailwind config with named tokens:

```js
theme: {
  extend: {
    borderColor: {
      'controls-multiselector': 'var(--embeddable-controls-multiSelector-borderColor)',
    },
  },
},
```

Then reference them as standard utility classes like `border-controls-multiselector`.

#### Tailwind 4 note

The approach above is confirmed working with Tailwind 3. If you’re on Tailwind 4, some tweaks may be needed — reach out if you run into issues and we can help you through it.

## How Do I Call Table-Valued Functions With FILTER_PARAMS?

If your database has an existing **table-valued function (TVF)** that accepts parameters (e.g. a date range), you can call it dynamically from a Cube model using `FILTER_PARAMS`. The function executes with the exact range the user selects in the dashboard — no static table scan required.

**How it works**

Write the cube’s `sql` as a subquery that:

1. Uses `FILTER_PARAMS` twice — once to extract the `from` boundary, once for the `to` boundary — using a lambda that returns just one value each time.
2. Passes those values as parameters to your function via `CROSS JOIN LATERAL` (PostgreSQL) or the equivalent for your database.

```yaml
cubes:
  - name: my_tvf_cube
    sql: |
      SELECT t.*
      FROM (
        SELECT
          {FILTER_PARAMS.my_tvf_cube.event_time.filter(
            lambda x, y: f"{x}"
          )}::timestamp AS from_time,
          {FILTER_PARAMS.my_tvf_cube.event_time.filter(
            lambda x, y: f"{y}"
          )}::timestamp AS to_time
      ) params
      CROSS JOIN LATERAL public.my_function(params.from_time, params.to_time) t

    dimensions:
      - name: event_time
        sql: event_time
        type: time

      # ... other columns returned by your function
```

The `lambda x, y: f"{x}"` / `lambda x, y: f"{y}"` callbacks tell Cube to extract just the start or end boundary of the filter — rather than generating a full `col >= x AND col <= y` condition.

**Supported databases**

| Database | Lateral join syntax |
|----|----|
| PostgreSQL | `CROSS JOIN LATERAL my_func(from_time, to_time) t` |
| Snowflake | `TABLE(my_func(from_time, to_time))` in the `FROM` clause |
| BigQuery | `CROSS JOIN UNNEST(my_tvf(from_time, to_time))` |
| SQL Server | `CROSS APPLY dbo.my_func(from_time, to_time)` |

**Can a TVF cube join to other models?**

Yes. You can define `joins` on a TVF cube exactly as you would on any other cube. `FILTER_PARAMS` resolves correctly when the cube is queried alongside a joined model. A common pattern is enriching TVF results with a dimension table (e.g. businesses, users, products):

```yaml
joins:
  - name: businesses
    sql: "{CUBE}.business_id = {businesses}.id"
    relationship: many_to_one
```

Two things to keep in mind:

* **Only matched rows are returned** — dimension table rows with no corresponding TVF results are excluded. If a business has no transactions in the selected date range, it won’t appear in the results.
* **The join is defined on the TVF cube** — the TVF cube owns the foreign key and declares the `many_to_one` relationship to the dimension table.

**Do I need a TVF, or will a stored procedure work?**

You need a **table-valued function**. Stored procedures won’t work here.

The reason is that `CROSS JOIN LATERAL` (and its equivalents) require something that returns a result set — i.e. something you can `SELECT` from. TVFs satisfy this because they return a table. Stored procedures do not — they use `CALL` and have no return value that can sit in a `FROM` clause.

This applies across all supported databases:

| Database | Stored procedure | Table-valued function |
|----|----|----|
| PostgreSQL | `CREATE PROCEDURE` + `CALL` — not queryable | `CREATE FUNCTION ... RETURNS TABLE` ✓ |
| SQL Server | `CREATE PROCEDURE` + `EXEC` — not queryable | `CREATE FUNCTION ... RETURNS TABLE` ✓ |
| Snowflake | `CREATE PROCEDURE` + `CALL` — not queryable | `CREATE FUNCTION ... RETURNS TABLE` ✓ |

If you’re currently using a stored procedure, convert it to a table-valued function first. In PostgreSQL, that means replacing `CREATE PROCEDURE` with `CREATE FUNCTION ... RETURNS TABLE (...)`.

**Limitations**

* **Time ranges only** — the `x`/`y` callback only populates for `inDateRange` filters. Other filter types (equals, contains, etc.) don’t provide two boundary values.
* **No filter = likely error** — if the user doesn’t apply a date range, both values are `null`, which will typically cause a database error or return no rows. Enforce a default date range in your component to prevent this.
* **No pre-aggregation support** — pre-aggregations cannot accelerate queries built on TVFs.

## Related docs

* [Filter Params](https://cube.dev/docs/product/data-modeling/reference/context-variables#filter_params)

## Which Multi-Stage Calculations and Nested Aggregates Work in Embeddable (Cube v1.3.24)?

**Q: What are multi-stage calculations and nested aggregates in Cube?**

[Multi-stage calculations](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations) are computed measures that depend on the results of other aggregated measures — essentially, calculations built on top of calculations. [Nested aggregates](https://cube.dev/docs/product/data-modeling/recipes/nested-aggregates) are a related concept where one aggregate function is applied over the result of another. Both features allow you to express more complex analytical queries directly in your Cube data model.

---

**Q: Don't these features require the Tesseract SQL planner?**

According to Cube's documentation, multi-stage calculations and nested aggregates are listed as requiring the [Tesseract SQL planner](https://cube.dev/docs/product/configuration/reference/environment-variables#cubejs_tesseract_sql_planner) (enabled via the `CUBEJS_TESSERACT_SQL_PLANNER` environment variable). However, our testing with Cube v1.3.24 in the Embeddable workspace revealed that a significant subset of these features work correctly even without Tesseract fully enabled.

---

**Q: What exactly was tested?**

We created separate data models for each feature — multi-stage calculations and nested aggregates — and validated them against the Embeddable workspace running Cube v1.3.24. The goal was to determine which capabilities are functional out of the box and which are blocked by the absence of full Tesseract support.

---

**Q: What features work in Cube v1.3.24 without Tesseract?**

The following features were validated and work correctly:

| Docs | Feature | Notes |
|----|----|----|
| [Rolling Window](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#rolling-window) | Rolling window (trailing, unbounded) | Date range filter required |
| [Period-to-date](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#period-to-date) | Period-to-date (type: to_date YTD/QTD/MTD) | Date range filter required |
| [Time-shift](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#time-shift) | Time shift (time_shift) | ✅ |
| [Fixed dimension](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#fixed-dimension) | Fixed dimension / percent of total (group_by) | ✅ |
| [Nested aggregated (add_group_by)](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#nested-aggregate) | Nested aggregate (add_group_by) | ✅ |
| [nested aggregated (sub_query: true)](https://cube.dev/docs/product/data-modeling/recipes/nested-aggregates) | Classic nested aggregates (sub_query: true) | ✅ No Tesseract needed |
| Listed here on [docs](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations). | Pre-aggregations with multi-stage | ❌ Not accelerated — documented Cube limitation, not version-specific |

**Q: What features do NOT work in Cube v1.3.24?**

| Docs | Feature | Why it fails |
|----|----|----|
| [Ranking](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#ranking) | type: rank on measures | Build error — not in accepted enum values |
| [Switch in dimension](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#example-3) | type: switch on dimensions | Build error — not in accepted enum values |
| [Conditional Measure](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#conditional-measure) | Conditional measure (case/switch) | Blocked by type: switch not being supported |
| [Rolling Windows without filter](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#stages) | Rolling windows without a date range filter | Runtime error: "Time series queries without dateRange aren't supported" — resolved in Tesseract |

---

**Q: Why do rolling windows require a date range filter?**

In Cube v1.3.24 without Tesseract, time series queries — including rolling windows and period-to-date calculations — require an explicit date range filter to function. Without one, the query fails at runtime. Tesseract resolves this by supporting time series queries without a mandatory date range, but until Tesseract is fully available, you'll need to ensure a date range filter is always applied.

![image](https://docs.embeddable.com/img/faq/1cbb1d3346e99798a3c13c69132e3cb565fa8ddf_2_690x108.png)

---

**Q: What should I do if a feature I need isn't supported?**

If your use case depends on ranking, switch-based dimensions, conditional measures, or filterless rolling windows, these are currently blocked in Cube v1.3.24 without Tesseract. Your options include restructuring the logic using supported features (e.g., using `sub_query: true` for [nested aggregates,](https://cube.dev/docs/product/data-modeling/recipes/nested-aggregates) or applying date range filters for [rolling windows](https://cube.dev/docs/product/data-modeling/concepts/multi-stage-calculations#rolling-window)), or reaching out to the Embeddable or Cube support teams for guidance on workarounds. Full support is expected when Tesseract becomes available in a future Cube release.

---

**Q: Will full Tesseract support be available in a future version?**

Tesseract is an actively developed component of the Cube platform. Full support is expected in future releases, which would unlock the complete set of multi-stage and nested aggregate capabilities — including ranking, switch types, conditional measures, and filterless rolling windows. Check the Cube changelog and Embeddable release notes for updates on Tesseract availability.

## Do I Need to Provide Security Context in the Tokens API?

Technically, yes, `securityContext` is a required body value when using the tokens API to retrieve a token. Most users do need it, in order to enforce row level security. If row level security is not a concern, or you are enforcing it in some other way, or you’re testing, you can provide a blank object as the value and the tokens API will return successfully:

```
securityContext: {},
```

## How Do I Use OR Filters (e.g. country = FR OR CA) in Embeddable?

## Can I build an **OR** filter like `country = 'FR' OR country = 'CA'`?

Yes — if you pass **multiple values** to a single filter, Embeddable treats it as an **OR** (SQL `IN`).

**Example (code-based datasets / `loadData`)**

```
loadData({
  filters: [
    { property: "country", operator: "equals", value: ["FR", "CA"] },
  ],
})

```

This generates SQL like:

```
WHERE country IN (?, ?)

```

---

### Why doesn’t it work if I add two filters?

Because **multiple separate filters** are combined with **AND** logic.

* ✅ **Single filter + array of values** → OR (`IN`)

* ❌ **Two filters on the same field** → AND (`country = 'FR' AND country = 'CA'`)

---

### Can I do this from the **Dashboard / Dataset UI** (no code)?

Yes — use this workaround:

#### Workaround: Multi-value **text variable**

1. Create a **Text** variable.

2. Enable **Multiple values**.

3. Enter each value on a new line, for example:

   ```
   FR
   CA
   
   ```

4. Go to your **dataset**, add a filter:

   * Operator: **equals**

   * Value: **connect it to the variable** you created

Result: the dataset will return rows where `country` is **FR OR CA**, which works well for things like **KPI components** that reuse a dataset.

---

### Can I build more complex logic like `(A AND B) OR C`?

Not yet. Dataset filters currently apply simple **AND across filters**. [Nested AND/OR logic is a roadmap item - give it a vote!](https://roadmap.embeddable.com/roadmap/support-for-nested-and-and-or-logic-in-dataset-filters)

## What’s the Difference Between Embeddable Managed Cube and My Own Cube Core / Cube Cloud?

## What are the two ways to use Cube with Embeddable?

Embeddable supports two ways of working with Cube:

### 1️⃣ Embeddable Managed Cube (Default)

This is the built-in, fully managed Cube layer that comes included with Embeddable.
It is the default experience and what most of our [documentation](https://docs.embeddable.com/) refers to.

With Embeddable Managed Cube:

* Data modelling is done inside Embeddable.

* Database connections are configured in Embeddable.

* Environments are managed in Embeddable.

* Caching and pre-aggregations are managed by Embeddable.

---

### 2️⃣ Cube Core / Cube Cloud (BYOC — Bring Your Own Cube)

In this setup, you run your own Cube instance:

* Self-hosted [Cube Core](https://cube.dev/docs/product/getting-started/core), or

* Managed [Cube Cloud](https://cube.dev/docs/product/getting-started)

You connect your Cube instance to Embeddable via the **[Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api)**.

With BYOC:

* All data modelling is done in your own Cube instance.

* Database connections are configured in Cube.

* Environments are managed in Cube.

* Caching and pre-aggregations are managed in Cube.

Embeddable connects only through the [Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api).

---

## Why does the UI look different for Cube Core / Cloud customers?

Most of Embeddable’s UI and [documentation](https://docs.embeddable.com/) assume you are using Embeddable Managed Cube.

If you are using Cube Core or Cube Cloud, some features will not appear or will not apply to you — and this is expected behaviour.

Below are the key differences.

---

## Why can’t I see the Data Model Editor?

The **[Data Model Editor](https://docs.embeddable.com/data-modeling/getting-setup)** is only available to Embeddable Managed Cube customers.

If you are using Cube Core or Cube Cloud:

* You define and manage models inside your own Cube instance.

* Those models are then synced into Embeddable.

* You do not need the Data Model Editor in Embeddable.

If you cannot see it, nothing is wrong — it simply doesn’t apply to your setup.

![image|690x372](https://docs.embeddable.com/img/faq/e888641e4ac561a64c1416738d7eced6c7e29e0d_2_690x372.jpeg)

![image|690x372](https://docs.embeddable.com/img/faq/74c6f34d905764054732f8c1673dff0618688f17_2_690x372.jpeg)

---

## What is the “Refresh” button next to Datasets for?

The **Refresh** button is specifically for Cube Core / Cube Cloud customers.

When you:

1. Make changes to your models in Cube, and

2. Want those changes reflected in Embeddable

You must click **Refresh** to sync the updated models via the [Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api).

![image|560x499](https://docs.embeddable.com/img/faq/3e21451aff54aaf1df1d9f98afce1470e6adadb6_2_560x499.png)

Embeddable Managed Cube customers do not typically need this.

---

## Do I need to use Environments or Connections in Embeddable?

No — not if you are using Cube Core or Cube Cloud.

The following pages are specific to Embeddable Managed Cube:

* **[Environments](https://docs.embeddable.com/data/environments)**

* **[Connections](https://docs.embeddable.com/data/connect-your-database)**

If you are using your own Cube instance:

* Your database connections live in Cube.

* Your environments live in Cube.

* Embeddable only connects through the [Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api).

---

## Which documentation sections do NOT apply to Cube Core / Cloud customers?

The following sections are written for Embeddable Managed Cube customers and are not operationally relevant to BYOC customers:

* Connect Your Data (except [Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api))

* Data Modelling (except [SQL-Based Security](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security) (row-level security))

* Caching / Pre-aggregations (managed within Embeddable)

* Embeddable Caching API

Important exception:
**[SQL-Based Security](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security) (row-level security) does apply to all customers**, including Cube Core / Cloud.

---

## Can Cube Core / Cloud customers still read the data modelling docs?

Yes.

The Embeddable data modelling docs are helpful for understanding concepts.

However:

👉 Your source of truth for modelling, schema definitions, caching, and pre-aggregations is the **[Cube documentation](https://cube.dev/docs/product/introduction).**

All configuration must be done in your Cube instance.

---

## What features apply to ALL customers?

The following areas apply equally to both setups:

* Building components

* Creating dashboards

* Embedding

* Theming

* Component SDK

* Row-level security ([SQL-based security](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security))

Everything related to the UI and embedding experience works the same way.

---

## How does Row-Level Security (RLS) work for Cube Core / Cloud customers?

All customers — including [BYOC](https://docs.embeddable.com/data/bring-your-own-cube) — can test RLS in the Embeddable Builder using:

```
presets/security-contexts.sc.yml
```

This file defines named security context presets used during testing.

### Example

```
- name: default
  securityContext:
    country: United States
    language: English
  dataProvider: default 
 
- name: main-instance
  securityContext:
    country: Germany
    language: German
  dataProvider: main-instance
```

Each preset:

* Defines RLS identifiers (e.g. `country`, `customer_id`)

* Specifies which `dataProvider` to use

This allows you to test [SQL-based security](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security) directly in the Embeddable Builder.

---

## How do Cube Core / Cloud customers connect to Embeddable?

You connect using the **[Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api)**.

That is the only required integration point.

You do NOT need to:

* Configure database connections in Embeddable

* Set up environments in Embeddable

* Create data models in Embeddable

All of that is handled in Cube.

---

## Where do I check errors?

If you are using Cube Core / Cube Cloud:

* Errors originating from Cube must be investigated in your Cube logs and monitoring tools.

* Embeddable does not have visibility into your Cube instance.

If you are using Embeddable Managed Cube:

* Our team has full log visibility.

* We can help investigate lower-level Cube issues directly.

---

## How Can I Sort by Days of the Week / Months of the Year in Remarkable?

## How can I sort days of the week in the correct order (Mon–Sun) in a table?

If you can’t sort by a field that isn’t displayed, the recommended workaround is to **map to a dimension that already includes the sort key**.

**Example approach**

1. **Create a new dimension in your model** that prefixes the label with a numeric sort value, for example:

   * `01 - Monday`

   * `02 - Tuesday`

   * …

   * `07 - Sunday`

2. **Use this new dimension in the table** (so sorting works correctly).

3. **Translate the displayed label** via your theme so users only see `Monday`, `Tuesday`, etc.

This ensures the table sorts correctly (by the numeric prefix) while still showing clean day names to end users.

---

### Why do I need to change the dimension instead of sorting by a hidden field?

In some setups, **sorting is only available on fields that are actually used in the visualization**. By embedding the sort value into the same dimension you display, you avoid needing a separate “hidden” sort field.

---

### Can I keep the numeric prefix from showing to users?

Yes — after you create the prefixed dimension (e.g. `01 - Monday`), you can add a **theme translation** that maps:

* `01 - Monday` → `Monday`

* `02 - Tuesday` → `Tuesday`

* etc.

So you get correct ordering *and* clean labels.

## How Do Security Tokens Behave?

### Do you support domain restrictions for tokens?

Not currently.

At the moment, tokens can be used on any domain. That said, the practical risk is low:

* Tokens are generated using your API key (which should remain secure).

* An attacker would need to obtain a valid, unexpired token.

* Any embedded dashboard would only expose data that the token holder already has access to.

We’ve added domain restriction support as a roadmap item:
[https://roadmap.embeddable.com/roadmap/restrict-domain-for-security-token-use](https://roadmap.embeddable.com/roadmap/restrict-domain-for-security-token-use)

---

### Is there an endpoint to validate whether a token is still valid?

We don’t provide a token validation endpoint.

Embeddable tokens are standard JWTs. You can:

* Decode the token using any JWT library.

* Inspect the `exp` (expiry) claim in the payload.

* Check whether the token has expired.

Since tokens remain valid until their expiry time, checking the expiration date is all that’s required to determine validity.

**Recommended flow:**

1. Decode the token.

2. If it hasn’t expired, continue using it.

3. If it has expired, generate a new token.

---

### Can tokens be invalidated on logout (instead of relying on time-based expiry)?

Not currently.

Tokens are valid until they expire, and we don’t yet support manual invalidation (e.g. “logout” or “invalidate all tokens” flows).

We’ve added this as a roadmap item:
[https://roadmap.embeddable.com/roadmap/api-to-invalidate-security-tokens](https://roadmap.embeddable.com/roadmap/api-to-invalidate-security-tokens)

## How Do I Connect Embeddable to MySQL Version 8 / 8.4?

When connecting a MySQL 8 or MySQL 8.4 (LTS) database to Embeddable, you may encounter the following error:

```
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
```

This happens because MySQL 8+ uses `caching_sha2_password` as its default authentication plugin, while Embeddable connects successfully using `mysql_native_password`.

**How to Check Your MySQL Version and Authentication Plugin**

You can confirm your MySQL version and user authentication method with:

```
SELECT VERSION();
SELECT user, host, plugin FROM mysql.user WHERE user = 'your_user';
```

If:

* Your version is **8.x (especially 8.4)**, and

* The `plugin` column shows **`caching_sha2_password`**,

then this is the cause of the connection failure.

**Solution: Create a user/ Alter existing user with `mysql_native_password`**

To connect Embeddable to MySQL 8/8.4, create a user that uses `mysql_native_password` instead of the default authentication method as mentioned [here](https://cube.dev/docs/product/configuration/data-sources/mysql#connecting-to-mysql-8).

In MySQL 8.4, `mysql_native_password` is **disabled by default** and you must enable it at the MySQL server level.

### If MySQL is installed on a server or VM

1. Edit your MySQL configuration file (commonly one of the following):

   * `/etc/my.cnf`

   * `/etc/mysql/my.cnf`

   * `/etc/mysql/mysql.conf.d/mysqld.cnf`

2. Under the `[mysqld]` section, add:

```
mysql_native_password=ON
```

3. Restart MySQL:

```
sudo systemctl restart mysqld
```

or

```
sudo systemctl restart mysql
```

---

### If MySQL is running in Docker

Start the container with native authentication enabled:

```
--mysql-native-password=ON
```

(Refer to your container configuration for where to add this option.)

### If Using a Managed Service (e.g., RDS, Cloud SQL)

Some managed MySQL services may restrict authentication plugin configuration.

Consult your provider’s documentation to determine whether `mysql_native_password` can be enabled or whether users can be created explicitly with that plugin.

## Step 2: Create a Native Authentication User

Once `mysql_native_password` is enabled, create a new user:

```
CREATE USER 'emb_user'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'emb_user'@'%';
FLUSH PRIVILEGES;
```

or alter your existing user:

```
ALTER USER 'emb_user'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'emb_user'@'%';
FLUSH PRIVILEGES;
```

---

## Step 3: Use This User in Embeddable

Configure your Embeddable connection using:

* Host

* Database

* Port (typically 3306)

* Username: `emb_user`

* Password: your password

The connection should now succeed.

## How Do I Stay Up to Date With Embeddable Package Updates?

You can run `npm run embeddable:upgrade` to get the latest versions of all Embeddable NPM packages, including our SDKs and Remarkable Pro. This will update your `package.json` file automatically, and then you’ll need to run `npm i`. If you want to automate this process, we recommend setting up a cron job that runs the commands daily, along with the `npm run embeddable:build`and `npm run embeddable:push` steps (if desired).

You can then use [the Versions API](https://docs.embeddable.com/deployment/versions-api#publish-a-version-to-an-environment) to enable CI/CD publish steps.

## Do You Have a Figma for the Remarkable Components?

Yes! You can check it out here: https://www.figma.com/community/file/1581738195673665795

## Can I Track When My Custom Canvas Is Ready?

You absolutely can. We’ve introduced a new event, `customCanvasReady`, that you can listen for like this:

```
const handleCustomCanvasReady = () => {
  // do whatever you like here
}
element.addEventListener('customCanvasReady', handleCustomCanvasReady);
```

More information on handling events can be found in our [“Interacting With Your Embeddables”](https://docs.embeddable.com/deployment/interactivity) documentation.

## How Do the Default Environment and data_source Behave?

### Why does every environment require a default `data_source`?

Embeddable requires each environment to have a default `data_source` due to how the underlying data modelling layer (Cube.js) resolves queries. This is an implementation detail and is not a configuration requirement in most cases.

---

### How is the default `data_source` chosen?

When an environment is created, the default `data_source` is automatically assigned to the first connection included in the environment definition.

---

### When is the default `data_source` used?

The default `data_source` is only used if a model does not explicitly define a `data_source`. If all models specify a `data_source`, the default is never used.

---

### What is the default environment?

The default environment is an automatically generated environment that cannot be edited. It reflects the current set of available connections and exists as a fallback when no environment is explicitly specified. It is also used by Embeddable sample models.

## Why Can’t I Remove a Connection From the Default Environment?

The **default environment** is automatically generated and cannot be modified directly. This is intended behavior.

If you need to remove a connection from the default environment, delete the connection itself. When a connection is deleted, it is automatically removed from the default environment.

## Why Aren’t My Changes to Models / Components Showing in the Embeddable Builder?

If you have made a change to your models or components and it’s not showing within the Embeddable builder, these are the things to check:

* Make sure you have re-built your repo after your changes (`npm run embeddable:build`)
* Make sure you have pushed the re-built changes to your workspace (`npm run embeddable:push`)
* Refresh your browser
* Check your builder is using your latest models/components version (this should happen automatically)

If you’re still having issues please contact the team and we’ll be happy to help 😊

## Why Won't My Dev Server Work in Brave?

By default, Brave not only denies access to Localhost resources, but does not even enable its pop-up asking if you want to grant access or not. If you’re getting “please make sure your dev server is running” errors even though `embeddable:dev` is running, please try the following:

1. navigate to brave://flags
2. search for “localhost”
3. change “enable Localhost access permission prompt” to “enabled”
4. restart Brave
5. refresh the dev server window

This *should* give you a prompt asking you if you want to allow Embeddable to connect to local resources. If it doesn’t, it’s possible the setting has already been disabled. To correct that, you should be able to do the following:

1. Navigate to settings: privacy and security: site and shield settings: view permissions and data stored across sites
2. Click “[embeddable.com](https://embeddable.com)”
3. Click “app.\[your region\].embeddable.com”
4. Change “Localhost Access” to “Allow”
5. Refresh your dev server window

If you’re still running into trouble, don’t hesitate to reach out!

## How Do I Pick Which Remarkable Components to Include When Publishing to Our Workspace?

You can selectively choose which components are included from the Remarkable Pro chart library to appear in your workspace like so:

```
componentLibraries: [{
   name: '@embeddable.com/remarkable-ui',
   include: ['BarChart', 'DateRangePicker']
}],
```

## What Should I Check When Renaming Dimensions or Measures in a Cube Model?

### ⚠️ Important: Prefer `title` property Over Renaming (Best Practice)

If your goal is **only to change how a dimension or measure appears to end users**, **do not rename it**.

Instead, use the `title` property.

The `title` property is a **non-breaking way** to update display names without affecting:

* Cube model references

* Joins and pre-aggregations

* Embeddable dashboards

#### How the `title` Property Works

* `name` → Internal, stable identifier (used in all references)

* `title` → Display label shown to end users only

```yaml
cubes:
  - name: orders
    sql_table: orders

    dimensions:
      - name: customer_id
        sql: customer_id
        type: number
        title: "Customer ID"

    measures:
      - name: total_revenue
        sql: amount
        type: sum
        title: "Total Sales Revenue"
```

👉 **Only rename `name` when a true semantic change is required.**

If you must rename, follow the checklist below.

---

### 1. References Within the Same Cube

**Derived measures**
Check measures that reference other measures or dimensions.

```yaml
measures:
  - name: profit_margin
    sql: 100.0 * ({profit} / {revenue})
```

**Computed / filtered dimensions**
Look for dimensions that reference other dimensions or measures.

```yaml
dimensions:
  - name: is_completed
    sql: "{CUBE}.status = 'completed'"

```

---

### 2. References in Joins and Across Cubes

**Join conditions**
Update all join SQL that references the renamed field.

```yaml
joins:
  - name: customers
    sql: "{CUBE}.customer_id = {customers}.id"

```

**Cross-cube references**
Check other cubes that reference this field.

```yaml
sql: "{orders}.status"
```

---

### 3. Pre-Aggregation References

If the renamed field is used in a pre-aggregation, update:

* `measures`

* `dimensions`

* `time_dimension`

* `partition_dimension`

```yaml
pre_aggregations:
  - name: orders_by_month
    measures: total_revenue
    dimensions: status
    time_dimension: created_at

```

---

### 4. Embeddable Frontend Usage

If the renamed field is used as a **time dimension** in an Embeddable FE component:

* Ensure the **generated query in the Embeddable Builder** uses the new name

* Otherwise, the component will error due to a stale reference

### 5. Testing Process

After completing the rename:

1. **Global search**
   Search the entire project for the old field name to catch missed references.

2. **Direct usage tests**
   Run queries that reference the renamed dimension or measure directly.

3. **Indirect dependency tests**
   Test queries that rely on the renamed field indirectly (joins, derived measures, filters, pre-aggregations).

## How Can I See the Custom Canvas Dashboards My Users Have Created / Customised for Themselves?

The custom canvas created by a user gets stored against the `customCanvasState` key that you pass to Tokens API. This is explained in detail [here](https://docs.embeddable.com/deployment/custom-canvas). In order to see the dashboard that a user has created, simply generate a token using their `embeddableId` and their `customCanvasState` and use that to render an embeddable and you'll see exactly what they see. You can even pass `customCanvasReadOnly: true` to the Tokens API to make sure that you're only seeing a read-only view of what they see.

## What Changed in the Caching API Per-Environment Update?

### What’s changing

We’ve updated the Caching API to support per-environment management of scheduled refresh contexts. You can now update caching configurations for specific environments (e.g., “staging”) without affecting other environments (e.g., “production”).

### Do I need to change anything?

**No.** This update is fully backward compatible:

* If you use a single environment (default): No changes needed
* If you use multiple environments: No changes needed - the API now behaves more safely

### How did it work before?

Previously, `POST /api/v1/caching/refresh-contexts` replaced ALL scheduled refresh contexts for your workspace. This worked well for single-environment setups. For multi-environment setups, you needed to include all environments in every request to avoid overwriting them.

### How does it work now?

**Smart Replacement** (enabled by default):

* When you update contexts, only the environments being updated are replaced
* Other environments remain untouched
* Example: Updating “staging” contexts won’t affect “production” contexts

**Master Reset**:

* To clear ALL contexts across ALL environments, send an empty list: `{ "scheduledRefreshContexts": [] }`

### Are there new endpoints?

Yes! You can now manage contexts per environment:

| Method | Endpoint | Description |
|----|----|----|
| PUT | `/api/v1/caching/refresh-contexts/environments/{env}` | Replace contexts for a specific environment |
| GET | `/api/v1/caching/refresh-contexts/environments/{env}` | Get contexts for a specific environment |
| DELETE | `/api/v1/caching/refresh-contexts/environments/{env}` | Delete all contexts for a specific environment |

### Can I still use the global endpoint?

Yes. The existing `POST /api/v1/caching/refresh-contexts` endpoint works exactly as before, but now with smart replacement behavior - it only replaces contexts for the environments you’re updating.

### Example: Updating a specific environment

**Before (old behavior):**

```bash
# This would DELETE all contexts (including production!)
# then create only staging contexts
POST /api/v1/caching/refresh-contexts
{
  "scheduledRefreshContexts": [
    { "environment": "staging", "securityContext": {...} }
  ]
}
```

**After (smart replacement):**

```bash
# This only replaces "staging" contexts
# Production contexts remain untouched
POST /api/v1/caching/refresh-contexts
{
  "scheduledRefreshContexts": [
    { "environment": "staging", "securityContext": {...} }
  ]
}
```

**Or use the new environment-specific endpoint:**

```bash
PUT /api/v1/caching/refresh-contexts/environments/staging
{
  "scheduledRefreshContexts": [
    { "securityContext": {...} }
  ]
}
```

## Can I Change the Start Day for Weeks?

We don’t currently support changing the start day for weeks in Embeddable to anything other than Monday, but there *is* a workaround for it that will allow you and your users to select other options. You can extend the `granularity` type via your Cube models and a custom type file, [as described here](https://docs.embeddable.com/development/extending-types#update-your-data-models), to add a “Week starting on \[day\]” option to the picker. This won’t replace the existing “weekly” option, which will still consider Monday the start of the week, but it will make your other choice(s) available to your users.

## Why Do I See “This API Is Disabled for This Workspace and External System” When Using the Connections API?

This error means the [Connections API](https://docs.embeddable.com/data/connect-your-database#connections-api) is not available for your workspace setup.
If you’re using your **own Cube instance** instead of Embeddable’s hosted cube, you should use the [Data Provider API](https://docs.embeddable.com/data/cube-cloud#data-provider-api) instead.

Similarly, if you see this error while using the **Data Provider API**, it means your workspace is configured to use **Connections API** and not the Data Provider API.

## What Changed in the Pre-Aggregations / Level 2 Caching Update?

**What’s changing**
We’ve updated our pre-aggregations set-up to support more functionality: partitioning, incremental, and refreshKeys that you can use in your model.

**Can I use refresh keys directly in the model?**
Yes. You can pass a time period (e.g. “x hours”), an SQL parameter like `SELECT MAX(created_at) FROM orders`, or a cron schedule (e.g. “refresh at 8 AM”).

Here’s what your model and pre-aggregation looks like before and after the change:

![image|690x336](https://docs.embeddable.com/img/faq/ba3b863679264476b06e9802d224933eaa113932_2_690x336.jpeg)

**Do I still need to provide security contexts via the caching API?**
Yes - you’ll provide these via the caching API - [Cube docs here](https://cube.dev/docs/product/configuration/reference/config#scheduled_refresh_contexts). However the refreshInterval isn’t needed anymore.

Here’s what your caching api request looks like before and after the change:

![image|690x269](https://docs.embeddable.com/img/faq/3d72bef201576abe09570f4f8ecbdac3b2deb3c1_2_690x269.jpeg)

**Is there still a limit on security contexts?**
No. The old limit of 30 has been removed.

**Do I need to pass timezones?**
If your client requires a timezone, it must still be passed via the caching API.

We will be updating our main docs page shortly - bear with us 😊

## Why Am I Seeing an Error About "SWC" When I Run `embeddable:dev`?

SWC is a piece of technology used by Embeddable’s core SDK. When the node module for it is installed, it’s supposed to build a binary file, but this file doesn’t always get built reliably. If you run into the error, these steps should trigger a full rebuild:

1. Delete the `node_modules` folder
2. Delete `package-lock.json`
3. Re-run `npm install`

If you’re on Windows, you may need to make sure you have Microsoft Visual C++ Redistributable installed first: https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist

This should get you up and running!

## What's the Best Practice for the Automatic Granularity Pickers?

Whenever you choose a time-series Dimension, a granularity picker also shows up automatically. This behavior is intended to replace the previous need to define a granularity input in your `emb.ts` file. If you have built custom components that use granularity inputs, you have two options:

1. **Our suggested choice** - remove the granularity input and use the automatic granularity instead. This may require you to move from passing `dimensions` and `measures` separately to `loadData` and instead use `select` - see [the loadData documentation](https://docs.embeddable.com/development/loading-data) for examples.
2. The alternate choice - on your dimension definition in the `emb.ts` file, you can add `hideGranularity: true` to the `config` property to disable the automatic granularity. Here’s a full example:

```
    {
      name: 'xAxis',
      type: 'dimension',
      label: 'X-Axis',
      config: {
        dataset: 'ds',
        supportedTypes: ['time'],
        hideGranularity: true,
      },
      category: 'Chart data',
    },
```

## How Does Z-Index Stacking Work With Shadow DOM?

**What’s going on?**
Shadow DOM creates isolated stacking contexts. To ensure overlays (e.g., dropdowns) render above content below them, rows inside our component receive incrementing `z-index` values. This is intentional.

**Can I turn off the per-row `z-index`?**
No. It’s required for correct layering within a single Shadow DOM component.

**How do I control which component appears on top at the page level?**
Set `z-index` on the component’s host/container (outside the Shadow DOM). Don’t override internal row values.

```
/* Page-level layering between separate Shadow DOM hosts */
.component-a { position: relative; z-index: 2; } /* above */
.component-b { position: relative; z-index: 1; } /* below */

```

**Gotchas**

* `z-index` only works on positioned elements (`position: relative|absolute|fixed|sticky`).

* Large `z-index` jumps aren’t necessary - just ensure the intended order.

* Keep page-level stacking in the host; leave intra-component stacking to the component.

## What Are Best Practices for Running Embeddable in Angular?

Getting your Embeddable working in an Angular application is very straightforward, but there are a few small things you need to be aware of!

Embedding web components in Angular requires you to include their `CUSTOM_ELEMENTS_SCHEMA`in order to avoid throwing errors. This can be solved in the component TS file by importing `CUSTOM_ELEMENTS_SCHEMA`from `angular/core`and then referencing it in the options you pass to `@Component` like this:

```
@Component({
  imports: [RouterOutlet],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  selector: 'app-root',
  templateUrl: './app.html',
}) 
```

Once you have that working, you should be able to include your `em-beddable` webcomponent code in your app without seeing any errors. However, if you want to add dynamic client context values, you’ll need to go a bit further. We recommend adding a `clientContext` method that employs `signal` like this:

```
  protected readonly clientContext = signal(
    JSON.stringify({ theme: this.theme })
  );
```

And then to change the value, you’ll want to employ the `set` method like this:

```
this.clientContext.set(JSON.stringify({ theme: this.theme }));
```

(You would, in this example, run that command after the theme value changes)

Looking for more details? Check out `client-angular` in [our example web component repo](https://github.com/embeddable-hq/web-component-example/)!

## What Is the Maximum I Can Set the refreshKey to for the L1 Cache?

The maximum you can set the refreshKey for L1 caching is 2 minutes - i.e. the data will be refreshed every 2 minutes.

## How Do I Set Up Embeddable in a Yarn/Nx Monorepo?

1) Monorepo baseline (Yarn workspaces + Nx)

* Your repo uses Yarn workspaces, managed by Nx.

* All packages extend a root `tsconfig.json` and target modern ESM:

`{   "compilerOptions": {     "target": "ES6",     "module": "esnext",     "moduleResolution": "node"   } } `

2) Add an Embeddable app/package

* Create a new workspace package (e.g. `@your/embeddable`) based on the **Remarkable Pro Boilerplate** repository.

* Wire it into Nx for dev/build so you can use caching and a single command surface.

This standalone setup should run cleanly in the monorepo.

Just so you know

* You may see the SDK complain about not finding a TypeScript compiler. Running the command with `--force` is a safe workaround and is unrelated to the integrations below.

3) Start consuming shared code

When you’re ready to import code from other workspace packages, add a workspace dep and (optionally) a path alias.

**package.json**

`{   "name": "@your/embeddable",   "dependencies": {     "@your/insights": "workspace:*"   } } `

**tsconfig.json**

`{   "compilerOptions": {     "paths": {       "@your/insights": ["path/to/insights"]     }   } } `

Just so you know (and how to work around it)

When introducing **tsconfig paths** and **workspace dependencies**, some setups hit module-resolution edge cases (e.g., “can’t import from directory,” “module not found,” or CommonJS interop errors from deep deps). If you see that:

**Workaround A — Preferred: feed Embeddable clean ESM builds**

* Prebundle the shared package(s) you import into **ESM output** (e.g., `.es.js`) using your bundler of choice (Rollup, tsup, Vite build).

* Point your `emb.ts` imports at those built ESM entry points.

* In Nx, make your Embeddable build depend on the shared package build (so ESM outputs exist first).

This keeps responsibility clear: your shared packages output ESM; Embeddable then bundles those ESM inputs.

**Workaround B — Smooth CJS interop when needed**
If some private/first-party deps are CommonJS:

* In the Embeddable package `tsconfig.json`, enable:

  `{   "compilerOptions": {     "esModuleInterop": true,     "allowSyntheticDefaultImports": true   } } `

* Prefer ESM builds of your internal libs where possible, or export dual targets (`module` ESM + `main` CJS) and import the ESM entry.

**Workaround C — Resolve path alias reliably**

* Point alias paths to the **built ESM dist** of the workspace package (e.g., `dist/insights/index.es.js`) rather than raw source, so Embeddable sees standard ESM files.

* Alternatively, remove the alias and import via the package name (after building), which avoids path resolution quirks.

4) Nx target wiring (example)

Have the shared libs build first, then Embeddable:

`// apps/embeddable/project.json {   "targets": {     "build": {       "executor": "nx:run-commands",       "options": { "command": "embeddable build --force" },       "dependsOn": ["^build"] // builds upstream libs first     },     "dev": {       "executor": "nx:run-commands",       "options": { "command": "embeddable dev --force" },       "dependsOn": ["^build"]     }   } } `

5) Keep bundles lean

Prebundling per component can bloat size. A few easy wins:

* **Bundle per package**, not per component (one ESM entry that re-exports components).

* Mark packages **tree-shakable** (`"sideEffects": false` where valid).

* Import **named exports** so Embeddable can treeshake.

* Let Nx cache builds to avoid unnecessary rebuilds.

## How Can I Model Percentile Aggregates (10th Percentile, 90th Percentile, etc.) for Individual Fields in ClickHouse?

You can define percentile aggregates using ClickHouse’s native functions without needing `number_agg`. For example, to model the 90th percentile of a `latency_ms` field, use:

```
- name: latency_p90_ms  
  type: number  
  sql: quantile(0.9)(latency_ms)
```

This works directly with the `number` type and supports custom window functions like percentiles.

## Why Can't Embeddable Find My Database Connection in My Environment?

If you're seeing this error:
```
Embeddable Error: Could not find a database connection for data_source '[DATA SOURCE NAME]' in environment '[ENVIRONMENT NAME]'\"
```
The most likely culprit is that you are referencing that data source in one of your models, but it hasn't been mapped in all of your environments. All data sources referenced in your models must exist in all of your environments. So for example, if you have a data source called `postgres`, and environments called `staging` and `prod` you would want to create two connections:
1. `postgres-staging`
2. `postgrest-prod`

Then when configuring your environments, you would map the `postgres` data source to `postgres-staging` in the `staging` environment, and map the `postgres` data source to `postgrest-prod` in the `prod` environment. This ensures that your models will compile properly when using either environment.

## Why Is My KPI Compare Component Not Working?

If you're using the KPI Compare component and trying to compare “This Week” vs “Last Week" using the hard-coded date dropdowns, you will see issues with the component.

Good news - you don’t need a custom component—but you *do* need to connect it properly. The KPI Compare component relies on a **comparison date filter** to pass in two distinct time ranges. Hard-coding the dates inside the component won’t work. Instead, use the comparison date filter component and connect it via the generated date variables to ensure both ranges are applied correctly.

## Can I Link Items in the Table Component?

Yes!

What you'll need to do is provide a standard markdown-formatted link, like this:

`[Click Here](https://embeddable.com)`

And the table will detect that and convert it to:

`<a href="https://embeddable.com" target="_blank">Click Here</a>`

It’s improbable that you're storing links as markdown directly in their DB, so what you'll need to do is create a Measure in your model file(s) that does the conversion. Here's an example:

```
- name: link_to_product
   sql: FORMAT('[%s](%s)', name, 'https://www.google.com/search?q='||name)
   type: string
```

The SQL is taking the `name` of the product, and then concatenating it into a URL. You would probably not be linking to Google, but it’s the same basic strategy. This could get as complicated as you want, eg a URL that contains an id, a name, a tracking number, etc.

## Is There Any Way of Defining a Display Order of Components When a Mobile View Is Being Used?

Unfortunately this is not possible at the moment.  The order is based on the order (top-to-bottom, left-to-right) that your components are layed out on the canvas.

What you can do as a workaround is have a desktop version of the dashboard as one Embeddable, and then a separate Embeddable for the mobile view.  Then serve up the right Embeddable depending on the view

## How Can We Translate the Text That Is Entered Into the Inputs When Building a Chart?

If your platform is available in multiple languages, you may want to translate the text that you enter when creating charts in the Embeddable builder. For example, you might have a chart title input with the text "Welcome".

In this case you would write `labels.welcomeText` in the text field in the builder, then create this in the client-context preset file, and set the text “Welcome” there.

Then code your components so that you would first try to look for the text in the clientContext instead wherever there is a text field.

You can even do `labels.welcomeText|Welcome` where the part right of the pipe is the fallback. 

You can read more about [working with clientContext](https://docs.embeddable.com/development/client-context) here.

## What Changed in Cube Version v1.3.24?

We're very excited to announce that we've upgraded our internal Cube version from v0.35.34 to v1.3.24.

Exciting new features:

* Custom granularities (define your own granularities, like weeks starting on Sundays, non-standard quarters or custom intervals): [ https://cube.dev/blog/cube-core-v0-36-playground-2-0-custom-granularities-query-pushdown#custom-time-dimension-granularities ](https://cube.dev/blog/cube-core-v0-36-playground-2-0-custom-granularities-query-pushdown#custom-time-dimension-granularities)

* Performance improvements: [ https://cube.dev/blog/cube-core-v1-2-data-access-policies-hierarchies-and-folders-updates-to#performance-optimizations ](https://cube.dev/blog/cube-core-v1-2-data-access-policies-hierarchies-and-folders-updates-to#performance-optimizations)

Breaking changes:

* For anybody using Cube Views (top-level 'includes' and 'excludes' are no longer supported): [ https://cube.dev/blog/cube-core-v1-3-performance-improvements-and-upgrades#breaking-removal-of-top-level-includes-and-excludes-in-views ](https://cube.dev/blog/cube-core-v1-3-performance-improvements-and-upgrades#breaking-removal-of-top-level-includes-and-excludes-in-views)

* For anybody writing their models in JS (version of Node used by Cube has been updated): [ https://cube.dev/blog/cube-core-v0-36-playground-2-0-custom-granularities-query-pushdown#breaking-changes-to-docker-images ](https://cube.dev/blog/cube-core-v0-36-playground-2-0-custom-granularities-query-pushdown#breaking-changes-to-docker-images)

Coming very soon:

* Access policies (define row-level security in YAML rather than SQL): [ https://cube.dev/blog/cube-core-v1-2-data-access-policies-hierarchies-and-folders-updates-to#data-access-policies ](https://cube.dev/blog/cube-core-v1-2-data-access-policies-hierarchies-and-folders-updates-to#data-access-policies)

## Why Is My Embeddable Just a Blank White Box?

If you're seeing this behavior, the first thing is to make sure that you're not inserting any blank spaces at the end of your token value in your `<em-beddable>` code, as that can result in unexpected behavior. If you're confident that the token is being inserted correctly, the next thing to check is the network tab in your browser's developer tools (please perform a full reload once you're on that tab and have it set to recording). If you see any errors there, check the response for data that may help you diagnose the issue. If you're still having trouble, or if there are no errors, please reach out to support!

## Why Does My Embeddable Throw Crypto Errors When Running on a Custom Local Domain?

If you're seeing `crypto.randomUUID is not a function` when running on a custom local domain for development purposes (eg using `localdev.mysite.com:8080` instead of `localhost:8080`), the reason for the error is because browsers only allow use of security functions like Node crypto in either `https` or `localhost` environments, and don't recognize custom local domains as localhost. There's a way to override this in the browser, as mentioned in [this Stack Overflow link](https://stackoverflow.com/a/78397011/3093766).
1. Go to chrome://flags/#unsafely-treat-insecure-origin-as-secure.
2. Add the origin which you want to treat as secure i.e., [http://example.com:8080](http://example.com:8080/).
3. Relaunch Chrome.
4. Verify by visiting [http://example.com:8080](http://example.com:8080/) and typing crypto.subtle in the DevTools Console.

## Why Does My Build Break With Styled Components?

There's a known TypeScript issue with Styled Components that throws errors if you import them via the default import. An easy fix is, instead of using:
```
import styled from 'styled-components';
```
use:
```
import { styled } from 'styled-components';
```
This should allow your build to proceed, and allow you to use Styled Components as you're used to.

## How Do I Export an Embeddable as PDF?

Currently this is an [item on our roadmap](https://roadmap.embeddable.com/roadmap/end-users-can-download-embeddables-as-pdf). 

In the meantime, you can achieve this by building an export component and using a tool like https://restpack.io/ or [pdf.js](https://mozilla.github.io/pdf.js/) to export your dashboard.

## How Do I Test the securityContext With Cube Core in Embeddable When Using driverFactory?

The `securityContext` argument below is exactly the content of the `securityContext` as passed to [Tokens API](https://docs.embeddable.com/deployment/tokens-api#example-fetch-a-token). For testing in the Embeddable dashboard builder, you can follow the instructions [here](https://docs.embeddable.com/data-modeling/row-level-security#testing-security-contexts-in-embeddable).

module.exports = { driverFactory: ({ securityContext, dataSource }) => { ... } };

## Why Isn't My New Data Model Displaying?

If you have created a new model in Embeddable's data model editor, but it's not showing in your Data Playground or in the models options in the Embeddable builder, the most likely culprit is that the model is set to Public: false. You can see in the "More configuration" options for your model, there is a setting called "Public". When this is set to "False", the model will not be visible in Embeddable. To enable the data model to be used, set this to true.

![Screenshot 2025-06-09 at 11.08.19|690x240](https://docs.embeddable.com/img/faq/25eca7c17140eca99d182be0930aeb839aa02b95_2_690x240.png)

## Why Can’t I Sort in the Table Component Once a ‘Default Sort’ Is Set?

This is a known behaviour of the current table component - if you set a default sort, it overrides the table sorts. Similarly, I believe if you create any sorts with the "sort" button, it also overrides the table sorts. This has to do with the way `loadData` presently behaves, where once a value is in the props, it can't be removed - so even if it looks like the code is eliminating the `defaultSort` value, it'll still show up in the props.

## How Do I Build Dashboard Delivery in Embeddable?

Example implementation of dashboard delivery:

1. We built a UI page thats called reports - this allows users to select an "Embeddable" to display. On that page we built a Nav with a button called "Export". Clicking this button will open a dialog that supports the ability to add in some emails / cadence time that is recored in our DB. e.g [john@gmail.com](mailto:john@gmail.com)/Twice a week/3pm.

2. We wrote a client in the backend that will query Embeddable API's using `/web-component/v1/query` and builds up a payload - see below a short `api-documentation` that shows how we achieved this for one component - but the logic is repeatable for what ever components you want to choose. To query the api you can just follow the [documentation](https://docs.embeddable.com/deployment/tokens-api) to get your security token and then build your CSV from the attached .md
3. We then pop that payload into a Pub/Sub - Scheduler - Cron job ( How ever you want to achieve it ) and then hit what ever SMTP service provider you want to use to send the email

# Web Component Query API Documentation

## Step 1: Retrieve Widget Information

### API Endpoint
- URL: `https://app-api.eu.embeddable.com/web-component/v1/embeddable`
- Method: GET

### curl Command
```bash
curl 'https://app-api.eu.embeddable.com/web-component/v1/embeddable' \
  -H 'accept: */*' \
  -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  -H 'origin: [YOUR_ORIGIN]' \
  -H 'referer: [YOUR_REFERER]' \
  -H 'sec-ch-ua: "Not;A=Brand";v="24", "Chromium";v="128"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
```

### Response Structure
```json
{
  "embeddable": {
    "widgets": [
      {
        "id": "component_id",
        "inputConfiguration": {
          // ... other properties ...
        }
      }
    ]
  }
}
```

## Step 2: Extract Required Data

From the response, extract the following information for each widget:

1. `componentId`: `widgets[i].id`
2. `limit`: `widgets[i].inputConfiguration.limit.value`
3. `datasetId`: `widgets[i].inputConfiguration.ds.value.datasetId`
4. `inputName`: `widgets[i].inputConfiguration.columns.inputMeta.config.dataset`
5. `dimensions`: Extract all `name` properties from `widgets[i].inputConfiguration.columns.value`
6. `order`:
   - Start with `widgets[i].inputConfiguration.defaultSort.value.name` as the first item
   - Add remaining dimensions in the order they appear in `widgets[i].inputConfiguration.columns.value`

Example Python code to extract dimensions:
```python
dimensions = [item['name'] for item in widget['inputConfiguration']['columns']['value']]
```

### Explanation of the `order` parameter

The `order` parameter is an array of arrays, where each inner array contains two elements:
1. The dimension name
2. The sort direction ("desc" for descending or "asc" for ascending)

The first item in the `order` array should always be the default sort dimension, which is specified by `inputConfiguration.defaultSort.value.name`. The remaining items should be the other dimensions in the order they appear in `inputConfiguration.columns.value`.

For example, if `balances.account_id` is the default sort, the `order` array would look like this:

```json
[
  ["balances.account_id", "desc"],
  ["balances.account_number", "desc"],
  ["balances.country", "desc"],
  ["balances.account_code", "desc"],
  ["balances.amount", "desc"],
  ["balances.currency", "desc"],
  ["balances.balance_date", "desc"]
]
```

Example to construct this `order` array programmatically:

1. Start with the default sort dimension:
   ```python
   default_sort = widget['inputConfiguration']['defaultSort']['value']['name']
   order = [[default_sort, "desc"]]
   ```

2. Add the remaining dimensions:
   ```python
   dimensions = [item['name'] for item in widget['inputConfiguration']['columns']['value']]
   for dim in dimensions:
       if dim != default_sort:
           order.append([dim, "desc"])
   ```

## Step 3: Construct Query Payload

Using the extracted data, construct a payload for the query API:

```json
{
  "inputName": "<extracted_input_name>",
  "datasetId": "<extracted_dataset_id>",
  "dimensions": ["<dimension1>", "<dimension2>", ...],
  "order": [
    ["<default_sort_dimension>", "desc"],
    ["<dimension1>", "desc"],
    ["<dimension2>", "desc"],
    ...
  ],
  "offset": 0,
  "limit": <extracted_limit>,
  "componentId": "<extracted_component_id>",
  "timezone": "Europe/Amsterdam"
}
```

## Step 4: Query Data

### API Endpoint
- URL: `https://app-api.eu.embeddable.com/web-component/v1/query`
- Method: POST

### curl Command
```bash
curl 'https://app-api.eu.embeddable.com/web-component/v1/query?' \
  -H 'accept: */*' \
  -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  -H 'content-type: application/json' \
  -H 'origin: [YOUR_ORIGIN]' \
  -H 'referer: [YOUR_REFERER]' \
  -H 'sec-ch-ua: "Not;A=Brand";v="24", "Chromium";v="128"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36' \
  --data-raw '{
    "inputName": "ds",
    "datasetId": "[DATASET_ID]",
    "dimensions": [
        "balances.account_number",
        "balances.country",
        "balances.account_code",
        "balances.account_id",
        "balances.amount",
        "balances.currency",
        "balances.balance_date"
    ],
    "order": [
        ["balances.account_id", "desc"],
        ["balances.account_number", "desc"],
        ["balances.country", "desc"],
        ["balances.account_code", "desc"],
        ["balances.amount", "desc"],
        ["balances.currency", "desc"],
        ["balances.balance_date", "desc"]
    ],
    "offset": 0,
    "limit": 1000,
    "componentId": "[COMPONENT_ID]",
    "timezone": "Europe/Amsterdam"
  }'
```

### Example Payload
```json
{
  "inputName": "ds",
  "datasetId": "[DATASET_ID]",
  "dimensions": [
    "balances.account_number",
    "balances.country",
    "balances.account_code",
    "balances.account_id",
    "balances.amount",
    "balances.currency",
    "balances.balance_date"
  ],
  "order": [
    ["balances.account_id", "desc"],
    ["balances.account_number", "desc"],
    ["balances.country", "desc"],
    ["balances.account_code", "desc"],
    ["balances.amount", "desc"],
    ["balances.currency", "desc"],
    ["balances.balance_date", "desc"]
  ],
  "offset": 0,
  "limit": 1000,
  "componentId": "[COMPONENT_ID]",
  "timezone": "Europe/Amsterdam"
}
```

### Explanation of the Example Payload:
1. `inputName`: Set to "ds" as specified in the original data.
2. `datasetId`: Taken from the `inputConfiguration.ds.value.datasetId`.
3. `dimensions`: List of all dimension names from `inputConfiguration.columns.value`.
4. `order`:
   - The first item is "balances.account_id", assuming it was the `defaultSort.value.name`.
   - The remaining items are all other dimensions, in the order they appear in `dimensions`.
   - All are set to "desc" (descending) order.
5. `offset`: Set to 0 to start from the beginning of the dataset.
6. `limit`: Set to 1000, as specified in the original `inputConfiguration.limit.value`.
7. `componentId`: Taken from the `id` field of the widget.
8. `timezone`: Set to "Europe/Amsterdam" as a default value.

## Notes
- Filters are automatically applied by the API and don't need to be included in the query payload - the data returned will be filtered automatically.
- The `timezone` and `variableValues` fields in the query payload are optional.
- Replace all placeholder values (marked with [BRACKETS]) with your actual values.

## If We Want to Use Our Own Datepicker, Is There Anything We Need to Be Aware of to Continue Using Other Embeddable Components?

As long as your datepicker outputs the same variables as our date picker, it should be fine. It's just a question of making sure the data coming from the datepicker is what our loadData is expecting in the Embeddable components. 

If you're hitting any issues reach out to us on Slack and we can help!

## Why Do I Get a Cube Error With embeddableIds in the Caching API?

If you are getting an error like so:

```
{
    "errorCode": "BUILDER-996",
    "errorMessage": "Request validation failed",
    "requestId": "ea7be19a-bac6-4feb-971e-028b136e689d",
    "errorMetadata": {},
    "underlyingErrorMessage": "Validation failed for field 'embeddableIds'. Reason: Instantiation of [simple type, class com.embeddable.backend.publicapi.dto.CreateScheduledSecurityContextsDto] value failed for JSON property embeddableIds due to missing (therefore NULL) value for creator parameter embeddableIds which is a non-nullable type"
}
```

Please check if you have any typos in your `embeddableIds` configuration - this is often caused by a stray ":" or similar 😊

If this does not resolve the issue, reach out to our team on Slack or on support@embeddable.com

## How Do Compound Filters Work in Embeddable?

We're currently limited to `AND` filters in Embeddable. If you would like to structure your filters like:
 `(A AND B) OR C`

You will need our upcoming feature: [Support for nested AND and OR logic in dataset filters](https://roadmap.embeddable.com/roadmap/support-for-nested-and-and-or-logic-in-dataset-filters)

You can see the current format in the Typescript definition:
![Screenshot 2025-05-22 at 11.39.49|376x165](https://docs.embeddable.com/img/faq/f90c09941b3fd7b0524589a62dd5c0d30206eb77.png)
![Screenshot 2025-05-22 at 11.40.11|492x108](https://docs.embeddable.com/img/faq/57fd203e430b4f12ea410a66cf07c1741ffcd5d0.png)

## What Is the Interval Is to Which Component Heights Snap in the Editor and How Does That Work With the defaultHeight That I Set?

The vertical snap is 21px. While you can set a default height, there's not currently a way to set a minimum height. So if you drag the component to be smaller than the default, it respects the new size you dragged to. When you set a defaultHeight, it renders to the nearest snap point, so eg a default height of `100` ends up at `106` when first inserted into the builder.

## How Do I Work Around TypeScript Errors?

If you are getting typescript errors, you can use `ts-ignore` or `ts-expect-error` for right now so they can continue developing. Please let our team know if you believe it is an issue on our side so we can get a ticket in.

## Why Is My Dropdown Filtering Itself?

When using a dropdown component, you will need to add a specific dataset (in the bottom right-hand modal) for your dropdown.

If you use the same dataset for your dropdown and to power your charts, when you select an option from the dropdown and pass that variable as a filter on the dataset, the dataset will be filtered everywhere it's used - including in your dropdown!

We suggest adding a specific dataset called 'dropdown dataset' or 'unfiltered dataset' for your dropdowns.

## Why Am I Getting 0 Results From My Pre-Aggregations?

**Getting 0 results**
If you are getting 0 results for a security context that you think should have data there are a few things you can try:

* Check that your environments are configured correctly for the pre-aggregations for the specific security context
* Check the query against your database using the Embeddable user to make sure the relevant permissions are there

## What Can We Change in the Theme File?

Here is the default theme used by Embeddable's out-of-the-box components:

```
import { Theme } from './theme';

export const defaultTheme: Theme = {
  brand: {
    primary: '#6778DE',
    secondary: '#FF997C',
  },
  charts: {
    colors: [
      '#6778DE',
      '#FF997C',
      '#9EA4F4',
      '#B8B8D1',
      '#FF6B6C',
      '#FFC145',
      '#9DC7FF',
      '#FF805B',
      '#CD9FFF',
      '#E6DEDE',
      '#FFA6A6',
      '#FFD98D',
    ],
    options: {
      toolTipEnabled: true,
      usePointStyle: true,
    },
    textJustify: 'start',
    fontWeights: {
      description: 400,
      kpiNumber: 700,
      pagination: 400,
      title: 700,
    },
    /* Custom overrides for certain charts */
    bar: {
      borderRadius: 4,
      borderSkipped: 'bottom',
      borderWidth: 0,
      font: {
        size: 12,
      },
    },
    bubble: {
      font: {
        size: 12,
      },
    },
    kpi: {
      alignment: 'center',
      font: {
        negativeColor: '#FF6B6C',
        size: 32,
      },
    },
    line: {
      font: {
        size: 12,
      },
      lineTension: 0.1,
    },
    pie: {
      font: {
        size: 12,
      },
    },
    scatter: {
      font: {
        size: 12,
      },
    },
    /* End custom chart overrides */
  },
  container: {
    backgroundColor: 'transparent',
    border: '1px solid #ddd',
    borderRadius: '12px',
    boxShadow: 'none',
    padding: '15px',
  },
  controls: {
    backgrounds: {
      colors: {
        heavy: '#D1D5DB',
        normal: '#F3F4F6',
        soft: '#FFFFFF',
        transparent: 'transparent',
      },
    },
    buttons: {
      active: {
        background: '#FFFFFF',
        border: '#D1D5DB',
        fontColor: '#000',
      },
      hovered: {
        background: '#FFFFFF',
        border: '#A1A5AA',
        fontColor: '#000',
      },
      pressed: {
        background: '#F3F3F4',
        border: '#D1D5DB',
        fontColor: '#000',
      },
      fontSize: '14px',
      height: '50px',
      paddingY: '16px',
      paddingX: '32px',
      radius: 'calc(infinity+1px)',
    },
    borders: {
      colors: {
        normal: '#DADCE1',
        heavy: 'D1D5DB',
      },
      padding: 8,
      radius: '12px',
    },
    datepicker: {
      backgrounds: {
        colors: {
          accent: '#f3f4f6',
          rangeEnd: '#7d899b',
          rangeEndDate: '#7d899b',
          rangeMiddle: '#f3f4f6',
          rangeStart: '#7d899b',
        },
      },
      font: {
        colors: {
          accent: '#7d899b',
          rangeEnd: '#ffffff',
          rangeMiddle: '#7d899b',
          rangeStart: '#ffffff',
          rangeStartDate: '#7d899b',
          today: '#111111',
        },
      },
      outsideOpacity: 0.4,
      radiuses: {
        buttonEnd: '0px 4px 4px 0px',
        buttonStart: '4px 0px 0px 4px',
        weekNumber: '4px',
      },
    },
    inputs: {
      colors: {
        hover: '#F3F4F6',
        selected: '#F3F4F6',
      },
    },
    tooltips: {
      radius: '4px',
    },
  },
  dateFormats: {
    year: 'yyyy',
    quarter: 'MMM yy',
    month: 'MMM yy',
    day: 'd MMM',
    week: 'd MMM',
    hour: 'eee HH:mm',
    minute: 'eee HH:mm',
    second: 'HH:mm:ss',
  },
  font: {
    color: '#888888',
    colorNormal: '#333942',
    colorSoft: '#e3e3e3',
    family:
      '-apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
    size: `14px`,
    weight: 400,
  },
  png: {
    backgroundColor: '#FFFFFF',
  },
  svg: {
    fillBkg: '#FFFFFF',
    fillNormal: '#474752',
    fillStrong: '#1D1E22',
    strokeSoft: '#474752',
    strokeNormal: '#959CA8',
    strokeStrong: '#101010',
  },
};

export default defaultTheme;
```

Here is the full `theme.ts` file with all the changes you can make to the theme:

```
export type ChartType = 'bar' | 'bubble' | 'kpi' | 'line' | 'pie' | 'scatter';

type ButtonSettings = {
  background: string;
  fontColor: string;
  border: string;
};

type BarChartBorderRadius = {
  topRight: number;
  topLeft: number;
  bottomRight: number;
  bottomLeft: number;
};

export type Theme = {
  brand: {
    primary: string;
    secondary: string;
  };
  charts: {
    colors: string[];
    options: {
      toolTipEnabled: boolean;
      usePointStyle: boolean;
    };
    textJustify:
      | 'start'
      | 'end'
      | 'center'
      | 'between'
      | 'around'
      | 'evenly'
      | 'stretch'
      | 'baseline'
      | 'normal';
    fontWeights: {
      description: number;
      kpiNumber: number;
      pagination: number;
      title: number;
    };
    bar: {
      borderRadius: number | BarChartBorderRadius;
      borderSkipped:
        | 'start'
        | 'end'
        | 'middle'
        | 'bottom'
        | 'left'
        | 'top'
        | 'right'
        | false
        | true;
      borderWidth: number;
      colors?: string[];
      font: {
        size: number;
      };
    };
    bubble: {
      colors?: string[];
      font: {
        size: number;
      };
    };
    kpi: {
      alignment: string;
      colors?: string[];
      font: {
        negativeColor: string;
        size: number;
      };
    };
    line: {
      colors?: string[];
      font: {
        size: number;
      };
      lineTension: number;
    };
    pie: {
      colors?: string[];
      font: {
        size: number;
      };
    };
    scatter: {
      colors?: string[];
      font: {
        size: number;
      };
    };
  };
  container: {
    backgroundColor: string;
    border: string;
    borderRadius: string;
    boxShadow: string;
    padding: string;
  };
  controls: {
    backgrounds: {
      colors: {
        heavy: string;
        normal: string;
        soft: string;
        transparent: string;
      };
    };
    buttons: {
      active: ButtonSettings;
      hovered: ButtonSettings;
      pressed: ButtonSettings;
      fontSize: string;
      height: string;
      paddingY: string;
      paddingX: string;
      radius: string;
    };
    borders: {
      colors: {
        normal: string;
        heavy: string;
      };
      padding: number;
      radius: string;
    };
    datepicker: {
      backgrounds: {
        colors: {
          accent: string;
          rangeEnd: string;
          rangeEndDate: string;
          rangeMiddle: string;
          rangeStart: string;
        };
      };
      font: {
        colors: {
          accent: string;
          rangeEnd: string;
          rangeMiddle: string;
          rangeStart: string;
          rangeStartDate: string;
          today: string;
        };
      };
      outsideOpacity: number;
      radiuses: {
        buttonEnd: string;
        buttonStart: string;
        weekNumber: string;
      };
    };
    inputs: {
      colors: {
        hover: string;
        selected: string;
      };
    };
    tooltips: {
      radius: string;
    };
  };
  dateFormats: {
    year: string;
    quarter: string;
    month: string;
    day: string;
    week: string;
    hour: string;
    minute: string;
    second: string;
  };
  font: {
    color: string;
    colorNormal: string;
    colorSoft: string;
    family: string;
    size: string;
    weight: number;
  };
  png: {
    backgroundColor: string;
  };
  svg: {
    fillBkg: string;
    fillStrong: string;
    fillNormal: string;
    strokeNormal: string;
    strokeStrong: string;
    strokeSoft: string;
  };
};

type ThemeDeepPartial = {
  [P in keyof T]?: T[P] extends object ? ThemeDeepPartial : T[P];
};

export type ThemePartial = ThemeDeepPartial;
```

## Can I Add Images to the Components?

Yes! If you want to add icons or images to your components, you can import all the required icons as modules inside the component and create a map of string values. Based on the value entered (i.e. the icon name) when configuring the component, the corresponding icon is displayed dynamically.

## Is It Possible to Have Different Calculations for Different Customers?

If you have customers in the UK and in the US, you might need different calculations for each region, for example due to tax. You can do this using `securityContext`. E.g.:

      - name: price_incl_tax
        type: sum
        sql: price * {COMPILE_CONTEXT.securityContext.tax_rate}

Where you would use '1' for countries with tax included, or 1.2 for the others.

## Is It Possible to Call a loadData Function After Finishing Another One?

Right now, we don't have an *official* way of doing `loadData(...).then(...)`, but we have a react hook called `useEmbeddableState` which you can use to "hack it" if you really need to`useEmbeddableState` basically allows you to pass `state` back and forth between your `.emb.ts` file and the react component (example [here](https://docs.embeddable.com/development/loading-data#2-filtering-example)). Because of that, you can set up a flow like this:

* first `loadData` runs in your `.emb.ts` file
* results are passed to react component
* you can use `useEmbeddableState` to pass appropriate state back to the `.emb.ts` file
* `.emb.ts` file reacts to the change of state, and calls the second `loadData` call

## Is There a Way That I Can Set a Font-Size for the HTML Element of the Embeddable Builder?

You can to override the rem setting by adding something like:

html { font-size: 16px !important // whatever you like }

to `custom-canvas.css` - this file gets injected at the top level of each Embeddable.

## Can I Create a Wrapper for My Embeddable?

In Embeddable, each component runs in its own instance of the shadow DOM and we don't have a container element around all of them that's defined in the component repo. However, you can create your own wrapper around your <em-beddable> code and style it however you like, and then adjust these lines in index.css to remove the border/padding/etc from every component:
:host(.inside-card) {
  /*  box-shadow: 0px 1px 4px rgba(28, 28, 33, 0.2);*/
  border-radius: 12px;
  padding: 15px !important;
  border: 1px solid #ddd;
}
Which would yield a similar result.

## Why Do I Get an “Invalid Token” Error From Cube Cloud?

If you are getting an error saying 'invalid token' and you are using a Cube Cloud connection to Embeddable, please check you authentication setup - usually this means something is interfering with the auth in Embeddable.

## Why Is My BOOLEAN Filter Not Working?

If you are using a BOOLEAN filter and you get an error like this:

![Screenshot 2025-03-11 at 09.25.55](https://docs.embeddable.com/img/faq/18663e453bf1eb62c3d2d4800a40df24c321e85e.png)

Check if your database supports TRUE/FALSE values. Certain databases, like MySQL, only support 0 and 1.

## Why Isn’t My Query Hitting My Pre-Aggregation?

Building pre-aggregations can allow you to take queries from a 5-minute loading time to **under a second** - great news! However, you might set up your pre-aggregation and find sometimes your query is still hitting your database. 

For example, let's say you have a pre-aggregation set up with the granularity "month". This means that any combination of whole months should hit the pre-aggregation.
If you want to test this, you can do so in [Cube’s playground](https://github.com/embeddable-hq/vanilla-components/blob/main/README.md#debugging-data-models) by trying different combinations of date ranges and seeing which get accelerated or not.

An example: if you apply a filter asking for 1st June to 31st August on your pre-aggregation that has the "month" granularity, then it can use a monthly pre-aggregation (by adding June, July and August together).
But if you ask for 1st June 11:00 to 1st September 11:00, even though it’s the same range of time, Cube can’t match this to a monthly pre-aggregation, as that pre-aggregation only has data from midnight to midnight, so no combination of the pre-aggregated data will give an accurate result. So it will miss the cache (as it should).

## Can I Include Nested Objects / Arrays in My securityContext?

You can nest your arrays/objects as deep as you like. Your `securityContext` is made up of any arbitrary JSON, so if it's valid JSON, it'll work.

## How Do I Troubleshoot My Databricks Connection?

If you get the following error following connecting your Databricks database:

```
errorCode: 'BUILDER-038'

```
Please try adding `EnableArrow=0` at last in the jdbc url, as suggested in https://community.databricks.com/t5/data-engineering/jdbc-driver-support-for-openjdk-17/td-p/32584

## How Can We Validate Data Integrity (e.g. After SQL Schema Change)?

If you want automated tests for your data integrity, the best way is to run tests against the REST API of a running cube container.

## What's the Difference Between "{CUBE}.id = {orders}.product_id" and "{CUBE}.id = {orders.customer_id}"?

You might sometimes see a join structured:

`"{CUBE}.id = {orders}.product_id"`

or

`"{CUBE}.id = {orders.customer_id}"`

Basically everything inside { and } relates to the cubes, whereas everything outside is SQL.
So `{orders}.product_id` references the `product_id` column in the database, whereas `{orders.customer_id` references the `customer_id` dimension in the `orders` model.

## How Do I Connect Different Environments in Cube Cloud?

You can set up branches in your Cube Cloud instance, for example for 'dev', and 'prod'. Then when you connect your Cube Cloud instance to Embeddable you can define which branch to use.

If you have separate Cube instances with their own CUBE_JS_API_SECRETs then we have a workaround, which is to set up 2 workspaces, each connected to a separate instance.

If you want to test two different Cube endpoints locally, you can run `embeddable:dev` like so:
`CUBE_CLOUD_ENDPOINT=some_url npm run embeddable:dev` 

In this case, you can point at any endpoint (unlike the production workspace, where it's only linked to one fixed endpoint).

Alternatively, you can add `CUBE_CLOUD_ENDPOINT` to a `.env` file

## How Can We Add Info to the Code Version in the Embeddable Builder?

In the builder you will see we have a 'code version' tab, which enables you to switch between different code versions that you have pushed. Sometimes it's helpful to add context to these code versions. You can do this by adding a message to your push step, like so:

`npm run embeddable:push -- --api-key  --email  --message `

## Do Pre-Aggregations Create Tables in My Database?

Yes, for certain database types, Cube will need to create tables in your database. You can [read more about Cube pre-aggregation strategies here](https://cube.dev/docs/product/caching/using-pre-aggregations#pre-aggregation-build-strategies).

If you want to check which strategy your database type uses, go to the [data sources page](https://cube.dev/docs/product/configuration/data-sources), select your database type and scroll down to 'Pre-aggregation build strategies'.

## Can We Rotate Our securityContext?

Yes, at the moment our team will need to help you with this. Please reach out via the Slack community or to your account manager to arrange this.

## How Does Embeddable's Caching Handle First Loading?

Embeddable has two types of caching, Level 1 cache (standard refresh cache) and Level 2 cache (custom indexes and materialised views for high performance).

* Level 1 cache is created on first load, so doesn’t speed up first load.
* Level 2 cache can be used on first load to retrieve data, so will speed up first load.

## How Should We Work With JSON Fields in Embeddable?

Some teams store custom data as a JSON inside a database field, like this: 
{"Ford": "Transit", "Renault": "Clio", "Volkswagen": "Polo"}

You can put as many fields in the JSON as you like. To use the values themselves in your charts you need to do one of two things:

1. define a separate dimension in your model for each field that you want to have access to, or
2. have a dimension that returns the whole JSON object, but then modify your chart component to handle the JSON object (i.e. use JavaScript to extract the values you need)

## How Do I Change the Default Limit in Components?

For the limit functionality, unset limits default to 100:
![Screenshot 2024-12-12 at 10.59.09|225x179, 100%](https://docs.embeddable.com/img/faq/bb59a7e404b10952e0f43f0dbedc2b537509c23c.png)
You can get around this by setting the limit in the loadData function that's in your emb.ts file, so for example if you don't want to give the user an option to adjust the limit via an input, you could do something like:
   
```
   results: loadData({
        from: inputs.ds,
        limit: 5000,
        dimensions: [inputs.xAxis],
        measures: [inputs.metric],
      }),
```
But if you do have an input that allows the end user to set their own limit, you could do:
 
```
     results: loadData({
        from: inputs.ds,
        limit: inputs.limit || 5000,
        dimensions: [inputs.xAxis],
        measures: [inputs.metric],
      }),
```

## Is There a Way to Filter Columns in a Data Model via Security Context?

Currently you cannot filter your columns in Embeddable, however you can have the columns show a blank result for certain customers - this really only makes sense in a table component, for example.

If you want to ensure certain customers do not have access to certain columns (i.e. column-level security instead of row-level security), the best way to do this is to create 2 Embeddables, one with the data you don't want to use hidden, and then to surface the correct Embeddable on your UI depending on the customer. 

This works best because alternatively, the customers who don't have access would see charts with 'no results' due to not having access to the dimensions (columns) required to populate the chart data.

## How Can I Clear the Cache?

If you have a scenario where you want to invalidate the cache you can:

* click publish
* call our cache API

Both of those actions will instantly cause the cache to refresh.

You can also have the cache clear programatically:

If you are using our L1 cache - i.e. using scheduled caching with  refreshKey, you can set your cache to refresh if there are new results:
- [Cube example here](https://cube.dev/docs/product/caching#refresh-keys)

If you are using our pre-aggregations cache (L2 cache) you can also do something similar, where if the results of the SQL refresh key differ from the last execution, then the pre-aggregation will be refreshed:

- [Cube example here](https://cube.dev/docs/reference/data-model/pre-aggregations#sql)

## Why Do I Get “Error: Password Authentication Failed”?

If you get an error stating: 'Error: password authentication failed' but you are sure you are using the correct password, please check if your password has a special character sequence, such as: 
`P\b\V-{`

You may need to add an additional backlash to escape the special characters, such as: 
`P\\b\\V-{`

## Are There Any Solutions for Displaying Something Outside a Component and on Top of Everything Else?

Embeddable automatically applies a z-index to every component on the canvas. This means that you can add additional components (e.g. tooltips, dropdowns, etc.) as long as they expand downwards - but not sideways or upwards. This is because z-indexes are lower as you go down the page.

If you want to add a component that opens as a new modal for example, to work around this, you could use the variable listener on the embedded web component (see [Embedding an Embeddable](https://docs.embeddable.com/deployment/interactivity#listen-to-variable-changes) in the handbook). That way you could listen to the appropriate variable change, and then open a modal in your react app, on top of the Embeddable dashboard.

## How Can I Customize Import Paths in Embeddable?

In Embeddable, you can customize your import paths (e.g. have absolute paths in your React components) and add path aliases.

To enable this, you need to add it in two places:

```
// embeddable.config.ts

{
     ...
      viteConfig: {
        resolve: {
          alias: {
            "@/custom-alias": path.resolve(__dirname, "src/custom-alias"),
          },
        },
      },
    }
```
```
// tsconfig.json (TypeScript configuration file placed in the root of the repository)

{
  "compilerOptions": {
    ...
    "paths": {
      "@/custom-alias/*": ["src/custom-alias/*"]
    }
  }
}
```
And finally, this will enable imports like
```
import SomeComponent from "@/custom-alias/Component"
```
Additionally, the following is required for __dirname and to work in the `path.resolve(__dirname, '../src/components')` :
```
import path from 'path'; import { fileURLToPath } from 'url'; // Get the equivalent of __dirname for ES modules const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename);
```

## How Do I Troubleshoot Embedding in Next.js?

If you are having an issue with embedding your Embeddable in a NextJs frontend, this could be due to the strategy.

Please make sure that the script has strategy=”lazyOnload”

If this does not resolve your issue, please get in contact with our team.

## Why Do I Get an Error With Cube Models in My Live Workspace (MySQL Database)?

If you are getting a 'Bad Request' error accessing your cube models in your live workspace and you are connected to a MySQL database you may need to update  your connection script to:

`ssl: false`

## Why Isn’t the MUI Select Popover Rendering Correctly?

When using the MUI select component in Embeddable, you might notice the popover may not render correctly. There are 2 options for using the Material UI select component:

1. Make usage of the native MUI components (in this case the NativeSelect).
2. Use the normal MUI Select, and try to restyle it.

These are example files:

```
Wrapper

import createCache from '@emotion/cache';
import { CacheProvider } from '@emotion/react';
import { CssBaseline, ThemeProvider, createTheme } from '@mui/material';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/node/AdapterDateFns/index.js';
import React from 'react';

const ThemeWrapper = ({ children }: any) => {
  const ref = React.useRef(null);
  const [cache, setCache] = React.useState<any>();
  const [theme, setTheme] = React.useState<any>();

  React.useEffect(() => {
    if (ref.current === null) return;

    const shadowContainer = ref.current.getRootNode() as ShadowRoot;
    const shadowRootElement = document.createElement('div');
    shadowContainer.appendChild(shadowRootElement);

    const cache = createCache({
      key: 'css',
      prepend: true,
      container: shadowContainer
    });

    setCache(cache);

    const theme = createTheme({
      components: {
        // If not using the NativeSelect, uncomment this block
        // MuiPopover: {
        //   defaultProps: {
        //     container: shadowRootElement
        //   }
        // },
        // MuiPopper: {
        //   defaultProps: {
        //     container: shadowRootElement
        //   }
        // }
      }
    });

    setTheme(theme);
  }, [ref]);

  if (!cache || !theme) return <div ref={ref}>loading...</div>;

  return (
    
      
        
          
          {children}
        
      
    
  );
};

export default ThemeWrapper;

```

```
select component

import {
  Button,
  FormControl,
  InputLabel,
  MenuItem,
  NativeSelect,
  Select,
  SelectChangeEvent
} from '@mui/material';
import React from 'react';

import MUI from './MUI';

type Props = {};

export default (props: Props) => {
  const [age, setAge] = React.useState('');

  const handleChange = (event: SelectChangeEvent) => {
    setAge(event.target.value as string);
  };

  return (
    
      
        {/* This commented Select, positions the popover no right bellow the select input */}
        {/* Style it to change the position of it (re-style classes), or make usage of the NativeSelect bellow */}
        {/* Age
        
          Ten
          Twenty
          Thirty
         */}
        
          Age
        
        
          <option value={10}>Ten</option>
          <option value={20}>Twenty</option>
          <option value={30}>Thirty</option>
        
      
    
  );
};

```

## How Should We Refresh the Token?

It's important that you never expose the API key to your frontend. What you can do to refresh the token is set it up so that whenever you want to update it, you call your server side to get a new token. That way, you don't need to expose the API key because it sits securely on your server side.

## How Do I Add Embeddable to My CI/CD Flow?

Just add these three steps to your CI/CD:
![Screenshot 2024-08-07 at 22.44.46|687x500](https://docs.embeddable.com/img/faq/4b8e7c3849afcc3ba8d130437c660adef3ce6e72_2_687x500.png)

[CI/CD example in the Versions API docs](https://docs.embeddable.com/deployment/versions-api#cicd-example)

## How Do I Use My Own Custom Font in Embeddable?

To use your own custom font, add it to our `constants.ts` file. The font will need to be hosted somewhere, e.g. in a public S3 bucket or google cloud storage or similar.

## How Do the Code Versions Work?

* each code version contains a snapshot of the code at the moment it was pushed

    * so if you switch to a previous code version (before a component was deleted) that component will be there (and will work as it used to)
    * i.e. deleting a component from your code does not delete it from a previous code version

* pushing a new code version (i.e. doing `npm run embeddable:push`) creates a new code version in the builder, but it does not affect the published dashboard until you re-publish

## How Do I Build a Tabbed Embeddable?

We have a simple example here of how to build a tabbed dashboard experience using Embeddable:
https://github.com/embeddable-hq/web-component-example/commit/0bb136290496085e18e49f877994180caced0e30

![Screenshot 2025-01-14 at 11.22.37|690x352](https://docs.embeddable.com/img/faq/8133b92cd5ba624bb721c8ed03d185455c57edf1_2_690x352.jpeg)

## How Can I Import amCharts?

You can import amCharts to use in Embeddable like so:

`useLayoutEffect(() => {`
`    import('@amcharts/amcharts5').then((am5) => {`
`      import('@amcharts/amcharts5/xy.js').then((am5xy) => {`
`        import('@amcharts/amcharts5/themes/Animated.js').then((am5themes_Animated) => {`
`          setAm5({ am5, am5xy, am5themes_Animated });`
`        });`
`      });`
`    });`
`  }, []);`

## How Can I Add Currency?

This can be achieved by using "meta.pretext" and "meta.posttext" in the data model. Additionally, many Remarkable Pro components support the ability to add custom formatting via sub-inputs on the dimensions or measures you've chosen.

## How Do I Get the Latest SDK Version?

You can always bump to the latest version by running:

`npx npm-check-updates -u "/@embeddable/"`

```
    "@embeddable.com/core": "2.5.7",
    "@embeddable.com/react": "2.5.8",
    "@embeddable.com/sdk-core": "3.3.1",
    "@embeddable.com/sdk-react": "3.3.1",
```
![image (2)|468x142](https://docs.embeddable.com/img/faq/4ec5f6e616801cac62988a83522a6349d9dd23ea.png)

## Can I Use Jinja?

You can use jinja in your Cube data models!
[Check out our SQL-based security docs to get started](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security#conditional-sql) using jinja pre-processing syntax in your data models
e.g.

```
cubes:
  - name: customers
    title: My customers
    sql: >
      select * 
      from public.customers 
	  {% if COMPILE_CONTEXT.securityContext.superUser %}
		where 1 = 1
	  {% else %}	
	    where organisationId in {{ list(COMPILE_CONTEXT.securityContext.orgIds) }}
	  {% endif %}
```

## How Do I Pass Variables via the Web Component?

We've added support to allow variables to be passed in via the web component, as well as listen to variable changes.
To interact with variables on the <em-beddable...> web component, you can define your Embeddable like so:

```
function Embeddable({token, onComponentsLoad, variables, onVariablesChange}) {
  const ref = React.useRef(null);
  function handleVariableChange(e) {
    if(onVariablesChange) {
      onVariablesChange(
        Object.fromEntries(
          e.detail.map(c => [c.variableName, c.newValue])
        )
      )  
    }
  }
  React.useEffect(() => {
    ref.current.addEventListener('variablesChange', handleVariableChange);
    ref.current.addEventListener('componentsLoad', onComponentsLoad);
    return () => {
      ref.current.removeEventListener('componentsLoad', onComponentsLoad);
      ref.current.removeEventListener('variablesChange', handleVariableChange);
    };
  }, []);
  return React.createElement('em-beddable', {
    ref, 
    token, 
    variables: JSON.stringify(variables)
  });
}
```
and then use it like so:

```

```

## How Do I Create Two Environments and Test Them in Embeddable?

A question we often get is how to create two environments - for example “Production” and “Staging” and test them in Embeddable. To achieve this, you can define your `.cube.yml` files like so:

```
cubes:
  - name: customers
    title: My customers
    data_source: default # can omit, as `data_source` has value `default` by default
    sql: >
        ...

```

And use the [Connections API](https://docs.embeddable.com/data/environments#define-connections) to provide your db credentials like so:

```
body: JSON.stringify({
	name: 'production-postgres',
	type: 'postgres',
	credentials: {
		...

```

and

```
body: JSON.stringify({
	name: 'staging-postgres',
	type: 'postgres',
	credentials: {
		...

```

and then just [create two environments](https://docs.embeddable.com/data/environments#create-environments) like so:

```
body: JSON.stringify({
	name: 'production',
	datasources: [
		{ data_source: 'default', connection: 'production-postgres'}
	]
})

```

and

```
body: JSON.stringify({
	name: 'staging',
	datasources: [
		{ data_source: 'default', connection: 'staging-postgres'}
	]
})

```

and then when [generating your security token](https://docs.embeddable.com/deployment/tokens-api), simply pass either "production" or "staging" to the `environment` field. When you pass "production" to the `environment` field it will dynamically map all the models whose `data_source` is "default" to the "production-postgres" database.  Whereas for "staging" it will map them to the "staging-postgres" database.

To test this in the Embeddable no-code builder, just update your `src/presets/security-contexts.sc.yml` file to specify the environment, like so:

```
- name: Example customer 1
  securityContext:
    country: United States
  environment: production

- name: Example customer 2
  securityContext:
    country: Germany
  environment: staging

```

Now you can test against staging data as well as production data in the builder, before clicking "publish".

## Why Do I Get an Error Using MUI AdapterDayjs?

If you run into an error such as:
`AdapterDayjs is not supported`

Please try to do the import as follows: `import { AdapterDayjs } from '@mui/x-date-pickers/node/AdapterDayjs/index.js';`

## How Can I Use React Material UI (MUI) in Our Components?

To use MUI with Embeddable, you'll need a wrapper. 

[Here is the simplest version, just using our MUI wrapper.](https://github.com/embeddable-hq/vanilla-components/blob/material-ui/src/components/vanilla/controls/MaterialDatePicker/index.tsx)

And the MUI wrapper itself has the `ThemeProvider` - [see example here](https://github.com/embeddable-hq/vanilla-components/blob/material-ui/src/components/vanilla/MUI.tsx)

## How Should I Handle Split Repos for Components and Data?

You can control what gets pushed from a repo in the `embeddable.config.ts` file. Specifically, you can set `pushModels` and `pushComponents` to `true` or `false` depending on whether you want to push models or components from that repo. This would allow you to have one repo for your components and another repo for your data models.

## Why Do I Get “Error: Self Signed Certificate in Certificate Chain” (Postgres)?

If you get this error:

```
Error: self signed certificate in certificate chain
```
Please change your SSL settings from:

```
{
  "name": "   ",
  "type": "postgres",
  "credentials": {
    "database": "  ",
    "host": "  ",
    "user": "  ",
    "password": "  ",
    "port": "  ",
    "ssl": "true"
  }
}
```

to:

```
 ssl: {
        rejectUnauthorized: false,
      }
```

And use the relevant instructions for `CREATE` or `UPDATE` from our [Connections API documentation](https://docs.embeddable.com/data/environments#define-connections)

## Why Do I Get “Error: Embeddable Version Mismatch”?

The error "Embeddable version mismatch" means that you have two dashboards using different code versions.
Please go to each of your dashboards in your workspace and "publish" them again, so that all published dashboards are using the same code version. If the issue persists, [please contact our team](https://join.slack.com/t/embeddableworkspace/shared_invite/zt-20b4f6s10-gULqO6riqutJcbUi_FJmZA).

## Does meta const Have to Be Statically Defined If I Want to Reuse Common Parts of Configuration?

In summary:

* yes, `meta` needs to be statically defined (it can’t be defined using a function, it must be defined using an object)
* but, since `sdk-*` version `3.0.0` it is possible to extract parts of the `meta` object into separate constants, and even import them from different files

## How Long Is a Token Valid For?

It's up to you! You define the token expiry - check out our [Tokens API documentation here](https://docs.embeddable.com/deployment/tokens-api)

## If I Have Different Schema in the Same ClickHouse Instance, Do I Need a Separate Connection?

For different schema in the same instance, we shouldn’t need to change the connection.  You can just change your SQL in your models to point to the new schema.

## Is the Embeddable Background Transparent?

Yes! It will be the color of wherever you embed the Embeddable. Note: the canvas background is white and we use a white background in the Preview.

## Are There Any Global Dependencies?

No, we use [Vite.js](https://vitejs.dev/) as our JavaScript bundler.

## How Does Embeddable Work With dbt?

[Check out our section here on how we work with dbt](https://docs.embeddable.com/data/using-cube-cloud-with-dbt)

## Why Am I Having Problems With the react-select Library?

Libraries like `react-select` use the `emotion` css framework.  Due to components in Embeddable sitting inside a `shadow DOM` you’ll need to wrap the components in the `cache provider` from Emotion.

Please see an example here:
![Screen Shot 2023-12-22 at 12.20.29 (1)|653x500](https://docs.embeddable.com/img/faq/1e311fe26368355b963ceb6fa94dcd6231acaec7_2_653x500.png)

Official documentation here: https://emotion.sh/docs/@emotion/cache

## How Does the Dev Environment Work?

The dev environment is a separate workspace where you can make changes and preview them locally, instead of doing a build -> push step every time.

If you want those changes to show in your live workspace (i.e. not Preview workspace) you need to do the `embeddable:build` + `embeddable:push` steps.

When you first create your dev workspace it will be automatically connected to our sample database. Pop us a message to get it hooked up to your database 😊

## How Do I Create an ‘Apply’ Button?

Detail:
The general idea is to `onClick` take the values of two variables and set them as the values of two other variables. The destination variables may be defined outside of the scope of this button, e.g. declared manually as part of the dashboard or declared by some other component on the dashboard.

Solution:

```jsx
import { EmbeddedComponentMeta, defineComponent } from '@embeddable.com/react';
import { Value } from '@embeddable.com/core';

import Component from './index';

export const meta: EmbeddedComponentMeta = {
  name: 'BasicButtonComponent',
  label: 'Basic Button',
  inputs: [
    {
      name: 'label',
      type: 'string',
      label: 'Label',
      description: 'The text on the button'
    },
  ],
  events: [
    {
      name: 'onClick',
      label: 'Click',
      properties: []
    }],
};

type Inputs = {
  label: string;
}

export default defineComponent(Component, meta, {
  props: (inputs) => {
    return {
      ...inputs
    };
  },
  events: {
    onClick: (e) => ({ })
  }
});
```

Then the `props` for your react button component will be:

```jsx
const { label, onClick } = props
```

Then in the builder, just assign one variable to the other like so:

![Screenshot 2024-01-03 at 10.41.31|281x500](https://docs.embeddable.com/img/faq/44e49ce4607dfb890ba01927e110ba3325815d4d_2_281x500.png)

For this case, you’d define two interactions (one for each variable)

## Do I Need to Pay for a License for a Charting Library (e.g. Highcharts)?

If you're using Embeddable's built-in [Remarkable Pro Components](https://docs.embeddable.com/component-libraries/remarkable-pro), you do not need to worry about additional licenses for the charting library. If you're bringing your own library (eg HighCharts), you are responsible for ensuring you have the appropriate licenses for any third-party libraries you use.

## How Is Mobile-Readiness Handled in Embeddable?

For mobile-readiness, we allow you to set a `mobileWidth` which is the width in pixels, under which, the dashboard will automatically jump to being a single column, with components one below the other.

## Can We Define Cubes With JavaScript Instead of YAML?

Yes! You can define data models using javascript `.cube.js` files

## How Do We Make Inputs Appear as Groups in the Component Modal?

To group inputs in the component modal, just set the "category" field for each input.

## How Do I Filter Data via Some Info in My URL?

You can use [Security Context](https://docs.embeddable.com/data-modeling/row-level-security/sql-based-security) to pass information from your URL into the Embeddable component.

For example, if you want to filter data based on the country specified in the URL, you can pass it via the security context when retrieving the security token:

```
const token = await fetch('/api/get-token', {
  method: 'POST',
  body: JSON.stringify({
    securityContext: {
      country: 'Ghana'
    }
  })
});
```

Then, in your Embeddable component, you can access this information and apply it as a filter.

You can also use [Client Context](https://docs.embeddable.com/component-libraries/client-context) to pass information from your frontend into the Embeddable component.

## Can I Connect Using an Older Version of Elasticsearch?

We currently only support connecting to Elasticsearch in the way outlined [here](https://cube.dev/docs/product/configuration/data-sources/elasticsearch)

## Can We Supply Filters and Have Them Stored So Users Return to a Pre-Filtered Embeddable?

You can preset a filter for our Custom Canvas dashboard using dashboardState. It will apply to all users of the dashboard. Note: for non-Custom Canvas dashboards, you can also do this but you’ll need to store their selected variables in your frontend and then pass them back into Embeddable when that user returns.

If you look at the [Tokens API](https://docs.embeddable.com/deployment/tokens-api), you’ll see we ask for a `user` key. This is so we can store a dashboardState against each user (e.g. remember which filters have been set).

## What Are Common BigQuery Errors?

### Timestamp error

`Error: No matching signature for operator >= for argument types: DATETIME, TIMESTAMP. Supported signature: ANY >= ANY at [4:87]`

If you come across this error, it’s because Cube expects Timestamps instead of DateTime objects. You can solve this by changing the SQL to:

```
sql: TIMESTAMP(partition_date) 
```

## Where Can I See Practical Examples of Components?

[You can check out our components here](https://remarkable.embeddable.com/)

## Which Datasources Does Embeddable Support?

Embeddable supports any of the databases supported by cube.dev - you can [find the list here](https://cube.dev/docs/product/configuration/data-sources).

---
Source: https://docs.embeddable.com/faq
