// sdk · React
رفيق React لـ @astroway/sdk
الرسمي `@astroway/react` على npm — غلاف رقيق Stripe-STYLE فوق `@astroway/sdk`. يرفع `AstrowayProvider` العميل إلى سياق React؛ hooks `useAstroway` و `useAstrowayQuery` و `useNatalChart` ترجع ثلاثية SWR-STYLE `{ data, error, loading }` مع لا依赖ات خارجية. يعمل مع React 18+، Next.js App Router (من خلال "use client")، Vite، CRA.
// 01 / install
التثبيت
npm install @astroway/react @astroway/sdk react استيراد: import { AstrowayProvider, useNatalChart } from '@astroway/react';
اعرض في السجل → @astroway/react
// 02 / highlights
المميزات
- سياق AstrowayProvider
- useAstrowayQuery + useNatalChart
- لا依赖ات خارجية
- رفيق Stripe-STYLE
- أنواع TypeScript الكاملة من @astroway/sdk
// 03 / first request
أول طلب
import { AstrowayProvider, useNatalChart } from '@astroway/react';
function App() {
return (
<AstrowayProvider options={{ apiKey: import.meta.env.VITE_AW_KEY }}>
<Chart />
</AstrowayProvider>
);
}
function Chart() {
const { data, error, loading } = useNatalChart({
date: '1990-07-14',
time: '14:30:00',
timezoneOffset: 3,
latitude: 50.4501,
longitude: 30.5234,
});
if (loading) return <p>Loading…</p>;
if (error) return <p>Error: {error.message}</p>;
return <pre>{JSON.stringify(data, null, 2)}</pre>;
} ابدأ مع React
10,000 رصيد مجاناً شهرياً. SDK مفتوح المصدر، يتم إنشاؤه من OpenAPI 3.1، ومتزامن دائماً مع الخلفية (backend).