Files
solidtime/resources/js/packages/composables/README.md
Gregor Vostrak df71051feb Add @solidtime/composables package for logic shared with desktop and the extension (#1430)
* add @solidtime/composables package shared by web, desktop and extension

* bump api to 0.0.8 and require it in composables

* drop the manual composables publish workflow
2026-12-01 17:22:44 +01:00

1.1 KiB

@solidtime/composables

Vue composables shared by the solidtime web app, the desktop app and the browser extension: time entry mutations, the timer, organization lists and the authenticated API client.

Each app keeps its own login flow and decides where the API client and the selected organization come from, by installing the plugin:

import { SolidtimeComposables, withAuthentication } from '@solidtime/composables';
import { createApiClient } from '@solidtime/api';

const client = withAuthentication(createApiClient(endpoint + '/api', { validate: 'none' }), {
    getAccessToken: () => accessToken.value,
    canRefresh: () => !!refreshToken.value,
    refreshAccessToken,
});

app.use(SolidtimeComposables, {
    apiClient: () => client,
    currentOrganizationId,
    currentMembershipId,
    selectOrganization: (organizationId) => { /* switch the membership */ },
});

Requires @tanstack/vue-query to be installed in the app.

What belongs here

Logic that more than one app needs and that does not render anything. Components belong in @solidtime/ui, the generated API client and types in @solidtime/api.