Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/04-get-started/01-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ slug: /installation

# Installation

### Set up with an AI agent

If you use a coding agent such as Claude Code, Cursor, or Codex, you can configure your development environment with it. Give it this prompt, and the agent will install only what is missing and verify the results.

```text title="Agent setup prompt"
Set up this machine for Serverpod development. Check what is already installed first and only install what is missing. Do not reinstall or upgrade anything without asking me.

1. Flutter: run `flutter --version`. If Flutter is missing, install the latest stable release for this OS following https://docs.flutter.dev/get-started/install. Use the Dart SDK bundled with Flutter, not a separate one.
2. Serverpod CLI: run `serverpod version`. If it is missing, run `dart install serverpod_cli` (if it was previously installed with `dart pub global activate`, run `dart pub global deactivate serverpod_cli` first). If the install fails because the installed Flutter is too old, stop and ask me whether to upgrade Flutter.
3. Make sure `flutter`, `dart`, and `serverpod` are on the PATH for new terminal sessions, including non-interactive shells.
4. Verify by running `flutter doctor`, `dart --version`, and `serverpod version`. Do not install the platform toolchains flutter doctor reports as missing (Android Studio, Xcode, Chrome) unless I ask.

Finish with a summary in exactly this format, one item per line and no other commentary. Leave out a section if it would be empty.

Already installed
- <tool> <version>

Installed
- <tool or package> <version>

Optional, not set up
- <item flutter doctor reports as missing> (<what it is for>)

Use these descriptions for the optional items: Android toolchain (Android apps), Xcode (iOS and macOS apps), Chrome (web apps), Linux toolchain (Linux desktop apps), Visual Studio (Windows desktop apps). After the list, ask if I want any of them installed.

Then ask me: "Do you want me to create a new Serverpod project?" and show the command to do it manually: `serverpod create <project_name>`.
```

### Prerequisites

Serverpod is tested on Mac, Windows, and Linux. Before you can install Serverpod, you need to have **[Flutter](https://flutter.dev/docs/get-started/install)** installed. Serverpod 4 requires Flutter 3.44.4 or later, which includes Dart 3.12.2.
Expand Down
20 changes: 18 additions & 2 deletions src/theme/CodeBlock/Buttons/CopyButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Swizzled from @docusaurus/theme-classic to strip leading shell prompts
* (`$ `) from text written to the clipboard. The prompt remains visible
* in the rendered code block, but the copied text is the runnable command.
* Also reports each copy to Google Analytics as a `copy_code_block` event.
*/
import React, {useCallback, useState, useRef, useEffect} from 'react';
import clsx from 'clsx';
Expand Down Expand Up @@ -62,20 +63,35 @@ async function copyToClipboard(text) {
return copy(text);
}

function reportCopyEvent(params) {
// gtag is absent on the dev server and behind ad blockers.
if (typeof window === 'undefined' || typeof window.gtag !== 'function') {
return;
}
try {
window.gtag('event', 'copy_code_block', params);
} catch {}
}

function useCopyButton() {
const {
metadata: {code},
metadata: {code, language, title: blockTitle},
} = useCodeBlockContext();
const [isCopied, setIsCopied] = useState(false);
const copyTimeout = useRef(undefined);
const copyCode = useCallback(() => {
copyToClipboard(stripShellPrompts(code)).then(() => {
setIsCopied(true);
reportCopyEvent({
page_path: window.location.pathname,
language,
block_title: typeof blockTitle === 'string' ? blockTitle : undefined,
});
copyTimeout.current = window.setTimeout(() => {
setIsCopied(false);
}, 1000);
});
}, [code]);
}, [code, language, blockTitle]);
useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
return {copyCode, isCopied};
}
Expand Down
28 changes: 28 additions & 0 deletions versioned_docs/version-4.0.0/04-get-started/01-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ slug: /installation

# Installation

### Set up with an AI agent

If you use a coding agent such as Claude Code, Cursor, or Codex, you can configure your development environment with it. Give it this prompt, and the agent will install only what is missing and verify the results.

```text title="Agent setup prompt"
Set up this machine for Serverpod development. Check what is already installed first and only install what is missing. Do not reinstall or upgrade anything without asking me.

1. Flutter: run `flutter --version`. If Flutter is missing, install the latest stable release for this OS following https://docs.flutter.dev/get-started/install. Use the Dart SDK bundled with Flutter, not a separate one.
2. Serverpod CLI: run `serverpod version`. If it is missing, run `dart install serverpod_cli` (if it was previously installed with `dart pub global activate`, run `dart pub global deactivate serverpod_cli` first). If the install fails because the installed Flutter is too old, stop and ask me whether to upgrade Flutter.
3. Make sure `flutter`, `dart`, and `serverpod` are on the PATH for new terminal sessions, including non-interactive shells.
4. Verify by running `flutter doctor`, `dart --version`, and `serverpod version`. Do not install the platform toolchains flutter doctor reports as missing (Android Studio, Xcode, Chrome) unless I ask.

Finish with a summary in exactly this format, one item per line and no other commentary. Leave out a section if it would be empty.

Already installed
- <tool> <version>

Installed
- <tool or package> <version>

Optional, not set up
- <item flutter doctor reports as missing> (<what it is for>)

Use these descriptions for the optional items: Android toolchain (Android apps), Xcode (iOS and macOS apps), Chrome (web apps), Linux toolchain (Linux desktop apps), Visual Studio (Windows desktop apps). After the list, ask if I want any of them installed.

Then ask me: "Do you want me to create a new Serverpod project?" and show the command to do it manually: `serverpod create <project_name>`.
```

### Prerequisites

Serverpod is tested on Mac, Windows, and Linux. Before you can install Serverpod, you need to have **[Flutter](https://flutter.dev/docs/get-started/install)** installed. Serverpod 4 requires Flutter 3.44.4 or later, which includes Dart 3.12.2.
Expand Down
Loading