client-methods
यह क्या करती है
यह स्किल बताती है कि Agent-Native ऐप के ब्राउज़र कोड में कौन से क्लाइंट मेथड और hooks इस्तेमाल करें। इसमें actions, ऐप स्टेट, नेविगेशन, अपलोड और सेटिंग शामिल हैं। यह इन ऐप में स्क्रीन लिखने वाले डेवलपर्स के लिए है।
कब इस्तेमाल करें
- ✓जब ब्राउज़र कोड को किसी app action से डेटा पढ़ना या बदलना हो।
- ✓जब कोई कंपोनेंट framework या किसी ऐप रूट को कॉल करना चाहता हो।
- ✓जब आप स्क्रीन कोड में अपलोड, auth या सेटिंग जोड़ रहे हैं।
Skill का लिंक
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-methods/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप सेटिंग स्क्रीन को कच्चे अनुरोधों के बजाय ऐप के नामित क्लाइंट मेथड से मान सहेजने वाली बना सकते हैं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट ज़रूरत के लिए कोई मौजूदा क्लाइंट मेथड या hook खोजता है जो फ़िट बैठे। वह कस्टम अनुरोध लिखने के बजाय वही मेथड इस्तेमाल करता है, ताकि authentication और error handling एक जैसे रहें।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Client Methods
Rule
Browser/client code imports named methods, hooks, or client modules instead of hand-writing REST calls to framework or app routes.
Why
Route shapes are transport details. If components and docs call
fetch("/_agent-native/...") or template /api/* routes directly, every caller
has to rediscover auth, base paths, request-source headers, JSON parsing, error
handling, optimistic updates, sync invalidation, and route quirks. A named client
method gives the UI, docs, and future agents one stable contract.
How
Look for an existing client API first.
Need Use App action reads/writes useActionQuery/useActionMutationfrom@agent-native/core/client/hooksImperative action calls callActionfrom@agent-native/core/client/hooksBrowser application state readClientAppState,writeClientAppState,setClientAppState,deleteClientAppStatefrom@agent-native/core/client/hooksNavigation/app-state sync useAgentRouteState/useSemanticNavigationStatefrom@agent-native/core/client/navigationAgent chat context Agent chat helpers from @agent-native/core/client/agent-chatAsk the user a multiple-choice question from app code askUserQuestionfrom@agent-native/core/client/agent-chat(renders inline in the agent panel; answer goes to the agent — do not build a custom modal)Live sync useDbSync,useChangeVersion,useChangeVersionsfrom@agent-native/core/client/hooksExtension iframe calls appAction,appFetch,extensionFetchfrom the extension runtimeAction fetch behavior: every
useActionQuery/useActionMutation/callActionrequest is bounded by a 60s timeout, and timeouts surface as errors instead of retrying silently.useActionQuerycancels superseded requests automatically via React Query's abort signal. For imperative calls,callAction(name, params, { method, signal, timeoutMs })accepts anAbortSignaland atimeoutMsoverride for legitimately long operations.If no client API exists, add the narrowest helper at the boundary.
- Put shared framework helpers in
packages/core/src/client/*. - Put template-local helpers in
templates/<app>/app/hooks/*,templates/<app>/app/lib/*, or an existing local client module. - Export reusable core helpers from the focused
@agent-native/core/client/*entry for their domain. Never recommend the deprecated broad@agent-native/core/clientbarrel in new code. - Keep raw
fetch,agentNativePath, and route paths inside that helper, not scattered through components or docs. - Add focused tests for URL construction, headers, response parsing, error shape, and any sync invalidation.
- Put shared framework helpers in
Teach the helper, not the route.
Docs, skills, examples, and generated code should show:
await setClientAppState("selection", selection, { keepalive: true });not:
await fetch("/_agent-native/application-state/selection", { method: "PUT", body: JSON.stringify(selection), });
Exceptions
Raw route calls are acceptable only inside low-level client helpers or for route-shaped protocols that cannot be hidden cleanly:
- multipart uploads
- streaming/SSE/WebSocket transports
- OAuth redirects and callback URL construction
- webhooks and external provider callbacks
- extension sandbox
appFetch/extensionFetch, which are themselves exposed client methods - tests that assert route construction
Even for exceptions, prefer a named helper as soon as more than one caller needs the behavior.
Don't
- Don't put
fetch("/_agent-native/..."),fetch(agentNativePath(...)), or template/api/*calls directly in React components for normal app data, actions, settings, or application state. - Don't document route calls as the way client code should do work.
- Don't add pass-through
/api/*routes just to make client fetches look simpler; expose an action and call it with action hooks. - Don't duplicate auth/session/base-path/request-source/error parsing logic in every component.
Related Skills
actions— app operations shared by UI and agent.context-awareness— application-state navigation and selection helpers.real-time-sync— keeping helper-backed UI reads fresh.server-plugins— when a new route is actually warranted.
References
- `references/legacy-client-fet
अक्सर पूछे जाने वाले सवाल
कच्चे अनुरोधों से क्यों बचें?
रूट का आकार आंतरिक विवरण है, और नामित मेथड auth, errors और अपडेट को एक जगह रखते हैं।
action पढ़ने के लिए कौन सा hook है?
स्किल पढ़ने और लिखने के लिए action query और mutation hooks का नाम बताती है।
क्या अब भी सीधे रूट कॉल कर सकते हैं?
स्किल कहती है कि पहले नामित मेथड खोजें, और जहां वह मौजूद हो वहां हाथ से लिखे कॉल से बचें।
जानकारी
लेखक का मूल विवरण
Client method surface rules. Use when wiring browser/client code to actions, application state, framework routes, app APIs, uploads, auth, or settings.
repo: BuilderIO/agent-native
लोकप्रियता
- GitHub स्टार
- 7.6k
- रैंकिंग में स्थान
- #13145
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
design-exploration
7.6kयह आपके एजेंट को UI के कई डिज़ाइन विकल्प साथ-साथ दिखाने, आपकी पसंद चुनवाने और फिर चुने डिज़ाइन को सुधारने में मदद करती है।
visual-edit
7.6kयह आपके एजेंट को चल रहे लोकल ऐप को विज़ुअल एडिटर में खोलने देती है, ताकि आप उसकी असली स्क्रीन एक साथ देखकर संपादित कर सकें।
turn-into-app
7.6kयह किसी वर्कफ़्लो, स्प्रेडशीट या प्रोजेक्ट को भरी हुई स्क्रीन वाले विज़ुअल ऐप में बदलती है, जिसके कंट्रोल के पीछे एजेंट काम करता है।
visual-plan
7.6kयह सादे टेक्स्ट वाली योजना को डायग्राम, फ़ाइल नक्शों, कोड अंश और खुले सवालों वाली इंटरैक्टिव विज़ुअल योजना में बदलती है।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।