Migrating to v1
Migrate from the old hook-based API to the composable measurements architecture
The old API (v0) was a direct port from @krakentech/blueprint-utils, built
around two opaque hooks (useMeasurements and useMeasurementFilters) that
were tightly coupled to @krakentech/blueprint-api.
The new API (v1) removes that dependency entirely. You bring your own GraphQL client, and the package handles state, fetching, grouping, transforms, and Coral compatibility through composable, tree-shakeable entry points.
What's changing
| Peer dependency | Before | After |
|---|---|---|
@krakentech/blueprint-api | Required | Removed |
@tanstack/react-query | Required | Optional (only @octopus-energy/measurements/react-query) |
react | Required | Optional (only useTimeframe, usePreferences hooks) |
nuqs | N/A | Optional (only @octopus-energy/measurements/storage/nuqs) |
Set up your GraphQL client
The old API used useApi() from @krakentech/blueprint-api internally. The new
API accepts any object satisfying the GraphQLClient interface:
interface GraphQLClient {
request<TResult, TVariables>(
document: TypedDocumentNode<TResult, TVariables>,
variables: TVariables,
): Promise<TResult>;
}import { useGraphQLClient } from "#/lib/auth/client";
const client = useGraphQLClient();import { getUserScopedGraphQLClient } from "#/lib/auth/server";
const client = getUserScopedGraphQLClient();Pass this client as the first argument to any function that fetches data (query options factories, fetch functions, and resolvers).
Install the package
npm i @octopus-energy/measurements@latestIf you were importing from @krakentech/blueprint-utils, you can remove it from
your dependencies once the migration is complete.
Choose your migration path
Pick the feature you're migrating.
EnergyOverview
Detailed consumption chart with timeframe navigation and cost/kWh toggle.
EnergySummary
Week-over-week comparison widget with percentage change indicators.
If you're migrating both features, start with EnergyOverview because the state management and data fetching setup is shared. Once EnergyOverview is working, EnergySummary only needs a different transform and compat mapping.