npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dc-google-reviews

v0.0.12

Published

Reusable Google Reviews widgets + API helpers for Astro projects.

Readme

Google Reviews for Astro

Reusable Google Reviews components, helpers, and API handler for Astro projects. Combine the exported widgets with the server handler to render ratings client-side while keeping Google Places API calls on the server with KV caching.

Project Layout

/
├── docs/                       # Integration notes + QA checklist
├── src/
│   ├── components/google-reviews/  # Widget, badge, inline bootstrapper
│   ├── lib/                        # Client + server helpers
│   ├── server/                     # API handler export
│   ├── styles/                     # Shared CSS bundle
│   └── index.ts                    # Package entry point
└── package.json

Scripts

| Command | Description | | --------------- | ------------------------------------- | | npm run build | Produces the distributable in dist/ | | npm test | Runs vitest suite for utilities | | npm run typecheck | Type-checks the package with TypeScript |

npm run build copies components/styles into dist/ alongside transpiled JS and type declarations so the published package is ready for direct consumption.

Using the Package

npm install dc-google-reviews
---
import {
  GoogleReviewInlineScript,
  GoogleReviewsWidget,
  GoogleReviewsBadge,
} from 'dc-google-reviews';
import 'dc-google-reviews/styles.css';
---

<GoogleReviewInlineScript />

<GoogleReviewsWidget
  placeId="YOUR_GOOGLE_PLACE_ID"
  businessName="Your Business"
  fallbackRating={4.9}
  fallbackReviewCount={237}
/><!-- ... -->

<GoogleReviewsBadge
  placeId="YOUR_GOOGLE_PLACE_ID"
  businessName="Your Business"
  fallbackRating={4.9}
/>
  • Multiple locations: render multiple <GoogleReviewsWidget> instances, each with its own placeId (often sourced from import.meta.env per site).
  • Customise CTA copy via the ctaText prop ({count} and {label} tokens supported).
  • Bundle the shared stylesheet once per project (see import above) to receive the default Google styling.

API Route

Create src/pages/api/google-reviews.ts in your Astro site:

import { googleReviewsHandler } from 'dc-google-reviews';

export const prerender = false;
export const GET = googleReviewsHandler;

Environment & Infra Checklist

  • Create a server-side Google Places API key with the Places API (New) enabled. Lock it down to your hosting IP/compute provider with Google Cloud restrictions.
  • Set GOOGLE_PLACES_API_KEY, GOOGLE_PLACES_DEFAULT_PLACE_ID, GOOGLE_REVIEWS_CACHE_TTL, and CRON_SECRET in .env (and mirror them in your hosting platform, e.g. Vercel). Never embed the API key in client bundles.
  • Attach Vercel KV so cached payloads persist across deployments.
  • Schedule a Vercel cron hitting https://<deploy-domain>/api/google-reviews?placeId=<ID>&force=true with Authorization: Bearer <CRON_SECRET> for daily refreshes.
  • Provide fallbackRating/fallbackReviewCount values during builds to avoid UI flicker on first paint.

Detailed architecture, prop docs, and QA steps live in docs/google-reviews.md.