connect-strava
Let each user connect their Strava account and work with their activities in the app
Plane: oauth_connection · Requires: capability external_integration, end-user connection strava
Steps:
1. useConnections — Render connect UI; call connect('strava'); handle error_code on the postMessage result (0.2.8+).
2. useAgent — With capabilities ['external_integration','data_access'], prompt the agent to fetch recent activities and UPSERT them into strava_activities (layer user) in exactly the doc_schema shape.
3. useCollection — Read strava_activities reactively ({ layer: 'user' }, refreshOnAgentComplete: true) — never parse chat text for data.
Writes strava_activities (layer user, writer agent) — required: activity_id, name, sport_type, start_date, distance_m, moving_time_s.
Examples
import { useConnections, useAgent, useCollection } from '@flowstack/sdk';
export function StravaPanel() {
const { connections, connect, isLoading } = useConnections();
const strava = connections.find(c => c.provider === 'strava');
const { query, isStreaming } = useAgent(undefined, {
capabilities: ['external_integration', 'data_access'],
});
const { documents: activities } = useCollection('strava_activities', {
layer: 'user',
sort: { start_date: -1 },
limit: 50,
refreshOnAgentComplete: true,
});
if (isLoading) return <p>Loading…</p>;
if (!strava?.connected) {
return <button onClick={() => connect('strava')}>Connect Strava</button>;
}
return (
<>
<button
disabled={isStreaming}
onClick={() =>
query(
'Fetch my 30 most recent Strava activities and upsert them into the ' +
'strava_activities collection (dedupe on activity_id), matching its doc schema.'
)
}
>
Sync activities
</button>
<ul>
{activities.map(a => (
<li key={a.activity_id}>{a.name} — {(a.distance_m / 1000).toFixed(1)} km</li>
))}
</ul>
</>
);
}
See also
reason-write-read · connect-oauth-service · useConnections · useAgent · useCollection
Source: sync-recipes.mjs ← https://sage-api.flowstack.fun/recipes.json · Also available in llms-full.txt and registry.json.