feat: add ?grab=1 query-flag loader integrations for Vite and Next.js#466
feat: add ?grab=1 query-flag loader integrations for Vite and Next.js#466devin-ai-integration[bot] wants to merge 3 commits into
Conversation
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7be5799. Configure here.
| script.src = ${src}; | ||
| script.crossOrigin = "anonymous"; | ||
| document.head.appendChild(script); | ||
| } catch (error) {} |
There was a problem hiding this comment.
Query flag ignored on client navigations
Medium Severity
The loader reads window.location.search only when the inline snippet runs (typically the first full HTML load). Client-side route changes that add or remove ?grab=1 / ?grab=0 do not re-run that logic, so enabling or disabling via the query flag can fail until a full reload even though the docs say ?grab=0 turns React Grab off.
Reviewed by Cursor Bugbot for commit 7be5799. Configure here.
…ourcemap config Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
|
Tested end-to-end — all scenarios passed, CI fully green. Test 1: Vite plugin — dev server (e2e-app) — PASS
Note: synthetic Ctrl+C doesn't fire in browser automation, so overlay was demonstrated via Test 2: Vite plugin — production build — PASS
Test 3: Next.js <ReactGrab /> (apps/website) — PASS
Sourcemaps: the Vite plugin now enables |


Summary
Adds opt-in loader integrations so React Grab can be enabled in any environment, including production, via a URL flag instead of being hardcoded to dev builds.
New entry points on the
react-grabpackage:react-grab/vite—reactGrab()Vite plugin that usestransformIndexHtmlto prepend an inline loader snippet into<head>.react-grab/next—<ReactGrab />component (plain inline<script>, works in both App routerlayout.tsxand Pages router_document.tsx).Both render the same tiny inline snippet (
createFlagLoaderSnippetinpackages/react-grab/src/utils/create-flag-loader-snippet.ts):sessionStoragepersistence keeps React Grab active across navigations/reloads within the tab session after visiting once with?grab=1;?grab=0turns it off.Shared options:
flag(query param name, default"grab"),src(script URL),enabled(setfalseto skip injection entirely).Other changes:
./viteand./nextexports + build entries (cjs/esm + dts), changeset, README docs.skills/react-grab/SKILL.mdwhitespace change is frompnpm format(oxfmt).Link to Devin session: https://app.devin.ai/sessions/5f712600fa3f47d4acc0965a2f1ac873
Requested by: @aidenybai
Note
Low Risk
Additive integrations and docs; optional third-party script load only when users opt in via URL flag, with no changes to core grab runtime behavior.
Overview
Adds opt-in production loading for React Grab via URL query flags (
?grab=1/?grab=true), withsessionStoragepersistence for the tab session and?grab=0to disable.New package entry points
react-grab/vite(reactGrab()plugin) andreact-grab/next(<ReactGrab />) both inject the same inline loader fromcreateFlagLoaderSnippet, which only fetches the global bundle when the flag is active. Shared options:flag,src,enabled. The Vite plugin can also turn onbuild.sourcemapby default (unless already set orsourcemap: false).Build exports and README docs for the query-flag loader are included;
skills/react-grab/SKILL.mdhas a minor formatting-only tweak.Reviewed by Cursor Bugbot for commit f173ecb. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds an opt-in flag loader for
react-grabviareact-grab/viteandreact-grab/next, so?grab=1can enable React Grab in any environment, including production. The flag persists for the tab session and?grab=0turns it off.New Features
react-grab/vite: Vite plugin that prepends an inline loader script viatransformIndexHtml, and enables build sourcemaps by default unless you already set them (sourcemap: falseto opt out).react-grab/next:<ReactGrab />component that injects the same inline script (works in App and Pages routers).?grab=1/trueor?grab=0/false, persists tosessionStorage, and conditionally injects<script src="https://unpkg.com/react-grab/dist/index.global.js" crossorigin="anonymous">.flag(default"grab"),src(override script URL),enabled(setfalseto skip), plus Vite-onlysourcemap(defaulttrue)../viteand./nextexports with build entries and docs updates.Migration
productionBrowserSourceMaps: trueinnext.config.ts.Written for commit f173ecb. Summary will update on new commits.