// sdk · React
Companione React per @astroway/sdk
Ufficiale `@astroway/react` su npm — un wrapper sottile nello stile Stripe per `@astroway/sdk`. `AstrowayProvider` solleva il client nel contesto React; gli hook `useAstroway`, `useAstrowayQuery`, `useNatalChart` restituiscono una tripla `{ data, error, loading }` nello stile SWR con zero dipendenze esterne. Funziona con React 18+, Next.js App Router (via "use client"), Vite, CRA.
// 01 / install
Installa
npm install @astroway/react @astroway/sdk react importa: import { AstrowayProvider, useNatalChart } from '@astroway/react';
Vedi nel registro → @astroway/react
// 02 / highlights
Funzionalità
- Contesto AstrowayProvider
- useAstrowayQuery + useNatalChart
- Zero dipendenze oltre react
- Companione nello stile Stripe
- Tipi TypeScript completi da @astroway/sdk
// 03 / first request
Prima richiesta
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>;
} Inizia con React
10.000 crediti gratis al mese. SDK open-source, generato da OpenAPI 3.1, sempre sincronizzato con il backend.