Skip to content

Add Copy Page button#8341

Merged
gaearon merged 1 commit intomainfrom
add-copy
Mar 8, 2026
Merged

Add Copy Page button#8341
gaearon merged 1 commit intomainfrom
add-copy

Conversation

@gaearon
Copy link
Member

@gaearon gaearon commented Mar 7, 2026

I really like that Next.js docs have a button like this so I figured maybe we can add one too?

I usually just use this to feed something specific into Claude when it struggles with an API or a concept.

copy.mov

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 126.96 KB (🟡 +483 B) 242.1 KB
/500 126.97 KB (🟡 +483 B) 242.11 KB
/[[...markdownPath]] 129.4 KB (🟡 +484 B) 244.54 KB
/errors 127.21 KB (🟡 +484 B) 242.35 KB
/errors/[errorCode] 127.19 KB (🟡 +483 B) 242.33 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

Sick

@gaearon gaearon merged commit 180364f into main Mar 8, 2026
11 checks passed
@gaearon gaearon deleted the add-copy branch March 8, 2026 00:59
@MaxwellCohen
Copy link

I was going to suggest using useTransition to manage the copied state notification. i.e. something like this

  const [copied, startTransition] = useTransition();

  async function handleCopy() {
    const cleanPath = asPath.split(/[?#]/)[0];
    try {
      const res = await fetch(cleanPath + '.md');
      if (!res.ok) return;
      const text = await res.text();
      await navigator.clipboard.writeText(text);
      startTransition(async() => {
        await new Promise((resolve) => setTimeout(resolve, 2000));
      });
    } catch {
      // Silently fail
    }
  }

If it is too late, feel free to disregard.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants