https://github.com/bholmesdev/astro-client-when-rainy-in-ny
Only hydrate components when you have rain water 😉
https://github.com/bholmesdev/astro-client-when-rainy-in-ny
Last synced: 11 months ago
JSON representation
Only hydrate components when you have rain water 😉
- Host: GitHub
- URL: https://github.com/bholmesdev/astro-client-when-rainy-in-ny
- Owner: bholmesdev
- Created: 2023-06-02T21:27:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-02T21:44:37.000Z (over 2 years ago)
- Last Synced: 2025-03-22T16:02:45.561Z (11 months ago)
- Language: Astro
- Homepage:
- Size: 47.9 KB
- Stars: 22
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Astro - `client:rainy-in-ny` 🌧
Yes, this actually shows you how to hydrate components ONLY when it's raining in NYC. Take that React `"use client"`!
## 🚀 Project Structure
These are the files you probably want to reference:
```sh
/
├── src/
│ └── components/
│ └── Counter.jsx # what we're hydrating
│ └── pages/
│ └── index.astro # uses `client:rainy-in-ny`
├── .env.example # sets WEATHER_API_KEY
├── client-rainy-in-ny.mjs # implementation
└── astro.config.mjs # applies client directive
```
## ⚙️ Setup
This directive relies on the WeatherAPI.com for requesting the current forecast. To get an API key, you can [create a free account here](https://www.weatherapi.com/docs/).
Then, create a `.env` file at the base of the project mirroring the `.env.example` template.
## 🧞 Commands
All commands are run from the root of the project, from a terminal:
| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:3000` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |
## 👀 Want to learn more?
Feel free to check [Astro's "custom client directives" documentation](https://docs.astro.build/en/reference/directives-reference/#custom-client-directives).