Next.js Discord

Discord Forum

Implementing Google Reviews in Nextjs 13

Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
Hey there 🙂

I managed to implement google reviews using the places API, but unfortunately this is a bit limited, as it seems I can only get 5 reviews of one location, and if I ever where to use this component for a website/customer with more than one location, I would be a bit in a mess...

So my idea is to use the My Business API and that's where the trouble really begins: I have no idea how to implement an OAuth 2.0 flow on a website without user-interaction...

Can anyone help me with this?

2 Replies

Asiatic LionOP
That's my current function:async function fetchReviews(): Promise<PlaceData> { const placeId = process.env.PLACE_ID; const apiKey = process.env.GOOGLE_PLACES_KEY; try { const response = await fetch(${placeId}&fields=review,url,rating&key=${apiKey}&reviews_no_translations=true&reviews_sort=newest`,);
const data = await response.json();
if (!response.ok) {
throw new Error('Failed to fetch');
const res = data.result ? : [];
//const url = data.result ? data.result.url : "";

const rating = data.result ? data.result.rating : 0;
const reviews = any) => {
return {
author: review.author_name,
link: url,
rating: review.rating,
text: review.text
return {rating, reviews};
} catch (e) {
return {rating: 0, reviews: []};
i am not clear what the problem you face. Now you are going to use your own API key instead of Google provider tokens of users.
so why do you still need OAuth, which allows you to get user's tokens via Google Auth provider?