<script> tag inside a React component does not run, so the SnapWidget code does not work when you paste it into a page. Use the @snapwidget/react package, which loads the script for you. You can use it in a Server Component. The same steps work for Facebook, X, TikTok, YouTube and review widgets.
In SnapWidget
- Create your widget, or open an existing widget from your dashboard.
- Click Install Widget.
- In the Install Widget window, click Copy Code.
Find your widget ID
Look at the code that you copied. Your widget ID is the value ofdata-widget-id. If your code has an <iframe>, your widget ID is the part of the address after /embed/.
For a review widget, your widget ID is the value of data-reviews-id, or the part of the address after /embed/reviews/.
These steps are for feed, grid and review widgets. They are not for popup and banner widgets.
In your Next.js project
-
Install the package:
-
Add the widget to the page where you want it to show, for example
app/page.js:
reviewsId in place of widgetId:
snapwidget-lightbox, your posts open in a pop-up. Add lightbox:
<div> in your code can have a style, for example style="aspect-ratio:750/500". It gives the widget its size and keeps its space on the page while the widget loads. To keep it, pass the same values as a React style:
Without the package
Load the script withnext/script and add the widget’s element:
data-reviews-id in place of data-widget-id.
If your code has lines with snapwidget-lightbox, your posts open in a pop-up. Use the package for that widget: it loads the pop-up files for you.
Ask your AI coding tool
Paste this prompt into Claude Code, Cursor or another AI coding tool. Put your widget ID in it first.Check your widget
Open the page in your browser. The widget shows your latest Instagram posts. If the widget is too narrow or too wide, give the element around the widget a width, for examplewidth: 100%.