// sdk · React
@astroway/sdk용 React 동반자
공식 `@astroway/react` on npm — `@astroway/sdk`를 위한 얇은 Stripe 스타일 래퍼. `AstrowayProvider`는 클라이언트를 React 컨텍스트로 올려주며, `useAstroway`, `useAstrowayQuery`, `useNatalChart` 훅은 외부 종속성 없이 SWR 스타일의 `{ data, error, loading }` 트리플을 반환합니다. React 18+, Next.js App Router(via "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
- react 외 종속성 없음
- Stripe 스타일 동반자
- @astroway/sdk의 전체 TypeScript 타입
// 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 크레딧 무료. Open-source SDK로, OpenAPI 3.1에서 생성되며 백엔드와 항상 동기화됩니다.