KBAISE/ for lovable
Library
Docs

Connect your app to Cube

about 15 minBuildingchecked 1h agoOfficial page
The short version

Connect your Lovable app to Cube to use the business metrics your data team already set up. This lets your app show consistent numbers in dashboards and reports without recreating calculations.

Anyone who needs to build apps that show consistent business metrics from a central source.

Do this, in order

  1. 1

    Make sure you have a Cube setup with at least one data model, a public web address for Cube Core if you're using it, and your Cube API secret or a long-lasting API token.

    These are the essential pieces of information Lovable needs to talk to your Cube setup.

  2. 2

    Go to 'Connectors' in Lovable, select 'Cube', and click 'Add connection'.

    This starts the process of setting up a new connection to Cube.

  3. 3

    Choose 'App + chat connector' and give your connection a name that helps you identify it later.

    This type of connection works both when you're building in chat and in your finished app, and the name helps you keep track of it.

  4. 4

    Decide if you will connect using your Cube API secret or an API token.

    The API secret option is generally easier as Lovable manages token refreshes, but the API token option is for when you can't share your secret or need specific security settings.

  5. 5

    If using the API secret option: Enter your Cube deployment's web address (host) and the API secret. Optionally, add a 'Security context' as a JSON object if your Cube data is filtered by things like customer or role.

    This tells Lovable where your Cube is and gives it the key to securely access your metrics, applying any necessary data filters.

  6. 6

    If using the API token option: Enter your Cube deployment's web address (host) and a valid API token that expires in 7 days or more.

    This tells Lovable where your Cube is and provides a pre-made key for access, useful if you have specific token requirements.

  7. 7

    Choose who in your Lovable workspace can use this connection, or keep it private to yourself.

    This controls access to the Cube data through this connection for other people in your team.

  8. 8

    Click 'Connect' to save the connection.

    Lovable will test the connection to make sure it can talk to your Cube setup and read your data model before saving it.

  9. 9

    After connecting, ask Lovable in your project chat to link your project to this new Cube connection.

    This makes the Cube data available for you to use in that specific project.

Paste this into your project

Link this project to Cube using the connection named "My Company Metrics".

Words decoded

Cube
A platform that helps manage and deliver consistent business numbers (metrics) from your data, often used for dashboards and reports.
Semantic Layer
A shared set of definitions for business numbers (like 'revenue' or 'customer count') that ensures everyone uses the same calculations, no matter which tool they use.
Measures
The actual numbers you want to track, like 'total sales' or 'number of users'.
Dimensions
Ways to break down or group your measures, like 'by region', 'by month', or 'by product category'.
Data Model
The structure that defines how your business numbers (measures) and their groupings (dimensions) are organized in Cube.
Structured Queries
A way to ask for data by listing specific measures, dimensions, and filters, rather than writing complex code.
Semantic SQL
A special type of SQL (a language for databases) that lets you ask for data using the business terms defined in your Cube data model, instead of raw database table names.
API Secret
A secret key that proves your identity and allows secure access to your Cube setup.
API Token
A temporary, secure pass that grants access to your Cube setup for a limited time or purpose.
Security Context
Information attached to a data request that tells Cube which specific data a user is allowed to see, for example, only data for a certain customer or role.
JSON Web Token (JWT)
A compact, secure piece of information used to prove who you are and what you're allowed to do when communicating between systems.
Reverse Proxy
A server that sits in front of other servers and forwards requests to them, often used to add security features like HTTPS.

Where people get stuck

  • Do not put your API secret or API token in a prompt, chat message, or your app's code, as this exposes sensitive credentials.
  • Relying on the security context in Cube's development mode (CUBEJS_DEV_MODE=true) is risky, as it might ignore security rules.
  • Using an API token that expires too soon (less than 7 days) will cause your app's queries to fail.
  • Changing your Cube API secret will invalidate all existing tokens signed with the old secret, breaking other apps or tools that use them.
  • The connection test only checks if Lovable can reach Cube and read the data model, not if the security context filters data as expected. Always test with a query after linking to a project.
  • Connecting to Cube Core without a public HTTPS hostname will not work.
  • Each Cube connection in Lovable uses a single security context, meaning all users of apps linked to that connection will see data filtered the same way. You cannot give each app user a separate security context through one connection.

The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.