Why GRWidget?
Two scripts
, one div
, and one stylesheet
to run.
- Lightweight - One JS file and two CSS themes all under 15KB
- Responsive - Shows three different columns layouts at different breakpoints
- Themes - Choose from a light or dark theme
- Zero Dependencies - Only CSS and JS
- Customization - Control which reviews show
Setup Instructions
Follow these steps to get your own widget running on your site:
-
Configure your Google Cloud project
-
Create your API key
-
Add a website restriction to your API key. Click your API key in Google Cloud developer console and select
HTTP referrers (web sites)
under application restrictions. Add your site's URL to the web restriction section -
Add two API restrictions to your API key. Click your API key in the Google Cloud developer console and select
restrict key
under API restrictions. Then add the following API's from the drop-down:
Maps JavaScript API
Places API -
Install GRWidget:
npm install GRWidget
-
Insert the code below into your project's
body
:
-
Replace
YOUR_API_KEY
with your API key from the script you added above:
-
Copy GRWidget's
src/
andimages/
directory into your project -
Choose either the
light.css
ordark.css
theme and link it inside thehead
tag.
-
Find your Place ID and save it to your clipboard
-
Replace the demo Place ID in the
index.js
file that you placed in yoursrc/
directory:
var request = { placeId: "ChIJldeDxyahVogRGKNE9zcaFt0", fields: ["name", "adr_address", "reviews", "rating", "user_ratings_total"], };
Customization Option
Edit this constant in index.js
to show reviews only over that score:
const LOWEST_REVIEW_SCORE = 3;