-
-
Notifications
You must be signed in to change notification settings - Fork 7
Add Vercel Toolbar integration #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Vercel Toolbar integration #448
Conversation
This commit integrates the Vercel Toolbar into the application to enable better collaboration and feedback. The toolbar is conditionally rendered based on the environment (development, preview) or if a user is authenticated in production. - Added @vercel/toolbar dependency. - Created VercelToolbarWrapper component in components/vercel-toolbar.tsx. - Integrated VercelToolbarWrapper into the root layout with a Suspense boundary.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main concern is the production access control: !!user is a very broad condition and may expose the Vercel Toolbar to any logged-in user, conflicting with the stated goal of limiting it to team members. Additionally, the environment checks rely on build-time inlined process.env values in a client component, which may not match runtime expectations depending on deployment/promotion flow.
Additional notes (1)
- Maintainability |
app/layout.tsx:97-102
TheSuspenseboundary here likely doesn’t do what you want.VercelToolbarWrapperdoesn’t suspend (noReact.lazy, nouse()), sofallback={null}is effectively unused. If you added this to avoid hydration issues, note that Suspense won’t prevent them unless the child actually suspends.
If your goal is to avoid SSR/hydration discrepancies for a client-only toolbar, consider a client-only dynamic import with ssr: false (or ensure the wrapper intentionally suspends).
Summary of changes
What changed
- Added Vercel Toolbar support via the new dependency
@vercel/toolbar. - Introduced a client component
components/vercel-toolbar.tsxexportingVercelToolbarWrapperthat conditionally renders<VercelToolbar />based on:NODE_ENV === 'development'NEXT_PUBLIC_VERCEL_ENV === 'preview'- presence of an authenticated
user
- Wired the wrapper into
app/layout.tsxunder aReact.Suspenseboundary withfallback={null}.
Files touched:
app/layout.tsxcomponents/vercel-toolbar.tsx(new)package.json(+@vercel/toolbar)bun.lock(lockfile update)
| export function VercelToolbarWrapper() { | ||
| const { user, loading } = useCurrentUser(); | ||
|
|
||
| if (loading) return null; | ||
|
|
||
| const isDevelopment = process.env.NODE_ENV === 'development'; | ||
| const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'; | ||
| const isEmployee = !!user; | ||
|
|
||
| if (isDevelopment || isPreview || isEmployee) { | ||
| return <VercelToolbar />; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmployee is derived as !!user, which effectively enables the toolbar for any authenticated user, not specifically “team members/employees” as described in the PR context. If production auth includes regular end-users, this could unintentionally expose the toolbar in production.
Consider tightening this to a role/claim check (e.g., user.isStaff, user.email domain allowlist, or a server-issued claim), and ideally gating with an explicit env flag so it can be disabled quickly without code changes.
Suggestion
Update the production gating logic to check a stricter authorization signal than !!user, and optionally add an explicit kill-switch env var.
Example:
- Add
NEXT_PUBLIC_ENABLE_VERCEL_TOOLBARfor dev/preview toggling. - Replace
const isEmployee = !!user;with a real predicate, e.g.const isStaff = user?.roles?.includes('staff') || user?.email?.endsWith('@yourdomain.com');(whatever your auth model supports).
Then gate with:
const enabledByEnv = process.env.NEXT_PUBLIC_ENABLE_VERCEL_TOOLBAR === 'true'
const isDevelopment = process.env.NODE_ENV === 'development'
const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
const isStaff = /* stricter check */
if (enabledByEnv && (isDevelopment || isPreview || isStaff)) return <VercelToolbar />
return nullReply with "@CharlieHelps yes please" if you’d like me to add a commit with this suggestion.
| const isDevelopment = process.env.NODE_ENV === 'development'; | ||
| const isPreview = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'; | ||
| const isEmployee = !!user; | ||
|
|
||
| if (isDevelopment || isPreview || isEmployee) { | ||
| return <VercelToolbar />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a client component, process.env.* values are statically inlined at build time. That’s fine for NODE_ENV and NEXT_PUBLIC_VERCEL_ENV, but be aware this isn’t a runtime check and can behave unexpectedly across builds/promotions (e.g., an image built for preview later promoted).
If you need runtime-accurate environment detection, prefer a server-provided flag (via props) or a lightweight endpoint that returns environment + entitlement, then render accordingly.
Suggestion
If environment/entitlement must be runtime-accurate, compute the “should show toolbar” decision on the server and pass it to the client wrapper.
Example approach:
- In a server component (or layout), compute
const showToolbar = /* env + auth */. - Render
<VercelToolbarWrapper enabled={showToolbar} />and in the client component only render based on the prop.
Reply with "@CharlieHelps yes please" if you’d like me to add a commit with this suggestion.
User description
Integrated the Vercel Toolbar into the project following the official documentation. The implementation ensures that the toolbar is active in development and preview environments, and for authenticated users in production, preventing unauthorized access in the production environment while still enabling it for team members.
PR created automatically by Jules for task 4985844314083333021 started by @ngoiyaeric
PR Type
Enhancement
Description
Integrated Vercel Toolbar for development, preview, and authenticated users
Created VercelToolbarWrapper component with conditional rendering logic
Added @vercel/toolbar dependency to project dependencies
Wrapped toolbar in Suspense boundary in root layout
Diagram Walkthrough
File Walkthrough
layout.tsx
Integrate Vercel Toolbar into root layoutapp/layout.tsx
vercel-toolbar.tsx
Create VercelToolbarWrapper with conditional logiccomponents/vercel-toolbar.tsx
authentication
authenticated users
users
package.json
Add Vercel Toolbar dependencypackage.json