Connect your app to the dbt Semantic Layer
You can connect your Lovable app to the dbt Semantic Layer to easily get important numbers and trends that your data team has already defined. This lets your app show consistent data without you needing to write complex database code.
Anyone building an app that needs to display consistent, pre-defined business metrics from dbt Cloud.
Do this, in order
- 1
Log in to dbt Cloud, go to your project's Semantic Layer settings, and copy the GraphQL API host, the environment ID, and create a service token with 'Semantic Layer Only' and 'Metadata Only' permissions.
These are the secret keys and addresses Lovable needs to find and securely talk to your dbt Semantic Layer.
- 2
In Lovable, go to 'Connectors', select 'dbt Semantic Layer', and click 'Add connection'.
This starts the process of setting up the link between Lovable and your dbt data.
- 3
Give your connection a clear name, then paste the GraphQL API host, environment ID, and service token you copied from dbt Cloud into the corresponding fields.
This tells Lovable exactly how to connect to your dbt Semantic Layer and which specific environment to use.
- 4
Decide who else in your Lovable workspace can use this connection by adjusting the 'Sharing' settings.
This controls whether only you or other team members can access and build with this dbt connection in their projects.
- 5
Click 'Connect' to finalize the setup.
Lovable will check if the details are correct and establish the connection, making your dbt metrics available for use.
Paste this into your project
Connect my app to the dbt Semantic Layer. I've got my dbt Cloud GraphQL API host, environment ID, and service token ready. I want to query governed metrics defined in dbt without writing warehouse SQL.
Words decoded
- dbt Semantic Layer
- A special part of dbt Cloud that stores official definitions for important business numbers (like 'monthly revenue') so everyone uses the same calculation, no matter where they look at the data.
- Governed metrics
- Important business numbers (like sales or active users) that have a single, agreed-upon definition, ensuring everyone in the company sees the same, consistent figures.
- MetricFlow
- The engine within dbt that takes your metric definitions and turns them into the actual database queries needed to get the numbers.
- GraphQL API
- A way for computer programs to ask for specific pieces of information from a server, like asking for a metric's value for a certain time period.
- Service token
- A special password that allows a program (like Lovable) to access specific parts of your dbt Cloud account without needing your personal login.
- Dimensions
- Ways to break down or categorize your metrics, like looking at 'revenue by region' or 'active customers by product type'.
- Time grains
- Different time periods you can view your metrics over, such as daily, weekly, monthly, or quarterly.
- Warehouse SQL
- The specific computer language used to ask questions directly to your company's main data storage system (data warehouse).
Where people get stuck
- Using an incorrect GraphQL API host, environment ID, or service token will prevent the connection from working.
- Forgetting to create a service token with both 'Semantic Layer Only' and 'Metadata Only' permissions will cause connection issues.
- Trying to use this connector with dbt Core instead of dbt Cloud, as it requires dbt Cloud with the Semantic Layer enabled.
- Attempting to query more than one dbt environment with a single connection; each environment needs its own separate connection.
- Expecting to modify dbt models or trigger dbt runs through this read-only connection.
- Sharing your service token publicly, as it functions like a password.
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.