Skip to content

feat: add npmjs.dev to playground links (#2314)#2495

Open
romansp wants to merge 1 commit intonpmx-dev:mainfrom
romansp:feature/2314-run-in-browser-npmjs-dev
Open

feat: add npmjs.dev to playground links (#2314)#2495
romansp wants to merge 1 commit intonpmx-dev:mainfrom
romansp:feature/2314-run-in-browser-npmjs-dev

Conversation

@romansp
Copy link
Copy Markdown
Contributor

@romansp romansp commented Apr 12, 2026

🔗 Linked issue

Resolves #2314.

🧭 Context

Simple solution to provide "Try on RunKit" alternative by linking to https://npmjs.dev/{packageName] and keep "how to run package in browser" out of npmx.dev scope.

📚 Description

Adds "npmjs.dev" to collapsible "Try it out" section in package sidebar. This PR makes a change to always add link to ad-hoc playground on npmjs.dev. Link is added last to the list and will always appear after official playgrounds, e.g. CodeSandbox or Storybook.

I originally considered to add this link to ExternalLinks.vue but "Playgrounds" seems to be a perfect fit for it. Downside of this solution is that "Try it out" section is now always present, which pushes Versions section down.

Open to hear feedback and iterate on this solution.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 12, 2026 10:08pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 12, 2026 10:08pm
npmx-lunaria Ignored Ignored Apr 12, 2026 10:08pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Added an npmjs.dev link to the package page, providing direct access to detailed package information.
  • Improvements

    • Enhanced the package link display logic for improved reliability and maintainability.

Walkthrough

The change modifies the playgroundLinks computed property to add an npmjs.dev link for every npm package, converting the implementation from declarative array spreading to an imperative builder pattern that constructs the links array with conditional additions.

Changes

Cohort / File(s) Summary
Package playground links
app/pages/package/[[org]]/[name].vue
Refactored playgroundLinks computed to always include an npmjs.dev link (https://npmjs.dev/${packageData.name}) alongside existing Storybook and readme-sourced playground links. Implementation changed from declarative array spread to imperative builder with early return when package data is unavailable.

Possibly related PRs

Suggested reviewers

  • danielroe
  • ghostdevv
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding npmjs.dev to playground links, matching the code modifications in the pull request.
Description check ✅ Passed The description is well-related to the changeset, providing context about adding npmjs.dev links to the Playgrounds section and explaining the rationale for this approach.
Linked Issues check ✅ Passed The pull request successfully implements the primary requirement from issue #2314: providing an npmjs.dev link as a RunKit alternative in the Playgrounds section to allow users to quickly run and explore packages.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding npmjs.dev links to the playgrounds section; no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/package/[[org]]/[name].vue 0.00% 14 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/pages/package/[[org]]/[name].vue (1)

75-89: Avoid duplicate playground entries before pushing links.

On Line 75 and Line 84, links are appended without dedupe checks. If the README already contains the same URL, this can create duplicate items and duplicate command IDs (URL-based) in app/components/Package/Playgrounds.vue (Lines 121-132).

Proposed patch
-  if (packageData.storybook?.url) {
+  if (packageData.storybook?.url && !links.some(link => link.url === packageData.storybook.url)) {
     links.push({
       url: packageData.storybook.url,
       provider: 'storybook',
       providerName: 'Storybook',
       label: 'Storybook',
     })
   }

-  links.push({
-    url: `https://npmjs.dev/${packageData.name}`,
-    provider: 'npmjs.dev',
-    providerName: 'npmjs.dev',
-    label: 'npmjs.dev',
-  })
+  const npmjsDevUrl = `https://npmjs.dev/${packageData.name}`
+  if (!links.some(link => link.url === npmjsDevUrl)) {
+    links.push({
+      url: npmjsDevUrl,
+      provider: 'npmjs.dev',
+      providerName: 'npmjs.dev',
+      label: 'npmjs.dev',
+    })
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/pages/package/`[[org]]/[name].vue around lines 75 - 89, The code pushes
new playground links into the links array (e.g., the Storybook block and the
npmjs.dev push) without checking for duplicates, which can create duplicate
items and duplicate URL-based command IDs in Playgrounds.vue; update the logic
around the links.push calls to first check whether a link with the same url (or
same provider+url) already exists in links (e.g., via links.some(l => l.url ===
packageData.storybook.url) or similar) and only push the new entry if not
present, ensuring both the Storybook and npmjs.dev additions are guarded to
prevent duplicate entries/IDs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/pages/package/`[[org]]/[name].vue:
- Around line 75-89: The code pushes new playground links into the links array
(e.g., the Storybook block and the npmjs.dev push) without checking for
duplicates, which can create duplicate items and duplicate URL-based command IDs
in Playgrounds.vue; update the logic around the links.push calls to first check
whether a link with the same url (or same provider+url) already exists in links
(e.g., via links.some(l => l.url === packageData.storybook.url) or similar) and
only push the new entry if not present, ensuring both the Storybook and
npmjs.dev additions are guarded to prevent duplicate entries/IDs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8be95c8d-e09d-4d4e-a811-9333354e38aa

📥 Commits

Reviewing files that changed from the base of the PR and between f70a11b and e74c83b.

📒 Files selected for processing (1)
  • app/pages/package/[[org]]/[name].vue

Copy link
Copy Markdown
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be added to the command palette too - also since the name npmjs.dev doesn't really describe what it is we may need to add a different description

@romansp
Copy link
Copy Markdown
Contributor Author

romansp commented Apr 13, 2026

Thank you for your review @ghostdevv.

Double-checked and all playground links are added automatically to the command palette here https://github.com/romansp/npmx.dev/blob/e74c83beac7443003a07612dbf1d5513a57a2352/app/components/Package/Playgrounds.vue#L121-L132. No additional changes are required.

Agreed that description should be updated. Here's other variants I considered, let me know which one fits better in your opinion.

  1. Run on npmjs.dev
  2. Try on npmjs.dev
  3. Explore on npmjs.dev

Here's how it looks with "Try on npmjs.dev".
Screenshot 2026-04-13 at 1 39 23 PM
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run npm package instantly (Try on RunKit alternative)

2 participants