// sdk · React
Companion React pentru @astroway/sdk
Oficial `@astroway/react` pe npm — un wrapper subțire în stil Stripe pentru `@astroway/sdk`. `AstrowayProvider` ridică clientul în contextul React; hook-urile `useAstroway`, `useAstrowayQuery`, `useNatalChart` returnează o triplă `{ data, error, loading }` în stil SWR cu zero dependențe externe. Funcționează cu React 18+, Next.js App Router (prin "use client"), Vite, CRA.
// 01 / install
Instaleaz
npm install @astroway/react @astroway/sdk react import: import { AstrowayProvider, useNatalChart } from '@astroway/react';
Vezi n registru → @astroway/react
// 02 / highlights
Caracteristici
- Context AstrowayProvider
- useAstrowayQuery + useNatalChart
- Zero dependențe beyond react
- Companion în stil Stripe
- Tipuri complete TypeScript de la @astroway/sdk
// 03 / first request
Primul 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>;
} Start cu React
10 000 de credite gratuite pe lun. SDK open-source, generat din OpenAPI 3.1, mereu sincronizat cu backend-ul.