# A kundli app in Next.js, ready to run

> A Next.js App Router app that turns a name, birth date, time and place into a kundli: a North Indian chart drawn as SVG, every planet's sign, degree, house and nakshatra, and the Vimshottari mahadasha timeline with the period running now.

Source: https://astronode.dev/templates/nextjs-kundli-app · Updated: 2026-12-05

## What it does

- A form for name, date, local time, latitude, longitude and UTC offset; a server action makes the two API calls, so each kundli costs two calls.
- Draws the North Indian (diamond) chart as a self-contained SVG component with inline styles - lift `components/NorthIndianChart.tsx` into any React app.
- Lists the planets and shows the dasha timeline, marking the mahadasha and antardasha running today.
- Also exposes `POST /api/kundli` returning the same data as JSON, for other clients.
- Shows the API's own error message on the page for a bad key, a plan that is too low, or invalid input.

## Endpoints and plan

*API calls the template makes*

| Endpoint | Used for | Plan |
| --- | --- | --- |
| `POST /v1/charts/birth` | Ascendant and the nine planets: sign, house, degree, nakshatra, retrograde | Free |
| `POST /v1/dasha/vimshottari` | Mahadashas with their antardashas (`levels: 2`) | Free |

Everything it calls is on the Free plan, so a Free test key runs the whole template.

## Where things live

| File | What it holds |
| --- | --- |
| `lib/astronode.ts` | Input validation, the two API calls, response mapping - start here to show more fields |
| `lib/chart-layout.ts` | House positions and label points for the diamond chart |
| `components/NorthIndianChart.tsx` | The SVG chart |
| `components/KundliForm.tsx` | The form and result tables (`useActionState`) |
| `app/actions.ts` | The server action holding the key |
| `app/api/kundli/route.ts` | The JSON route |

## Keys and deployment

- The API key is read from the server's environment and sent as `Authorization: Bearer <key>`; it never reaches a browser or an app bundle.
- `npm run check` runs the tests against API responses recorded in `test/fixtures/` - no key and no network, so it can run in your CI.
- Deploys as any Next.js app (`next build && next start`, or a Next.js host); set `ASTRONODE_API_KEY` in the host's environment, never with a `NEXT_PUBLIC_` prefix.
- On a public site, put rate limiting or sign-in in front of the form and `/api/kundli`: every submission spends your quota.
- There is no place search: the form takes coordinates and the UTC offset. Add your own geocoder for a consumer product.

## Questions

**Does the Next.js kundli template need a paid plan?**

No. Both endpoints it calls are on the Free plan, so a Free test key runs it end to end.

**Can I use the chart component without the rest of the app?**

Yes. `components/NorthIndianChart.tsx` and `lib/chart-layout.ts` have no dependencies besides React and take the birth-chart response as their input.

**Why are Rahu and Ketu not marked retrograde?**

The API returns `retrograde: true` for Rahu and Ketu, which always move backwards in mean-node terms, so the chart only marks the planets for which retrogression is news.

## Related pages

- [Integration: Next.js](https://astronode.dev/integrations/nextjs)
- [Recipe: North and South Indian charts](https://astronode.dev/recipes/north-south-indian-chart)
- [Recipe: a dasha timeline](https://astronode.dev/recipes/dasha-timeline)
- [All templates](https://astronode.dev/templates)
