<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR enhances the initialization script for Stack Auth by adding
support for `projectId` and `publishableClientKey` (pck) parameters when
initializing a Next.js client application. The changes include: 1)
Adding logic to pass these parameters from environment variables or
directly from arguments to the Next.js client configuration, 2) Updating
the layout template to use the client-side Stack app instead of the
server-side app in the provider component, and 3) Improving Bun lock
file detection by checking for both `bun.lockb` and `bun.lock` formats.
These changes ensure proper configuration of Next.js client applications
with the required Stack Auth credentials.
⏱️ Estimated Review Time: 5-15 minutes
<details>
<summary>💡 Review Order Suggestion</summary>
| Order | File Path |
|-------|-----------|
| 1 | `packages/init-stack/src/index.ts` |
</details>
<!-- RECURSEML_SUMMARY:END -->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Enhances Stack Auth init script with `projectId` and
`publishableClientKey` support, updates Next.js layout, and improves Bun
detection.
>
> - **Behavior**:
> - Adds `projectId` and `publishableClientKey` support to Next.js
client configuration in `index.ts`.
> - Updates layout template to use client-side Stack app in
`getUpdatedLayout()`.
> - Improves Bun lock file detection in `promptPackageManager()`.
> - **Options**:
> - Introduces `--on-question` option to control interactive prompts in
`index.ts`.
> - **Scripts**:
> - Standardizes test scripts to use `--on-question error` in
`package.json`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 67a98f5aba. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
----
<!-- ELLIPSIS_HIDDEN -->
<!-- RECURSEML_ANALYSIS:START -->
## Review by RecurseML
_🔍 Review performed on
[7a0bf86..0b443e4](7a0bf86cb3...0b443e460f)_
✨ No bugs found, your code is sparkling clean
<details>
<summary>✅ Files analyzed, no issues (1)</summary>
• `packages/init-stack/src/index.ts`
</details>
[](https://discord.gg/n3SsVDAW6U)
<!-- RECURSEML_ANALYSIS:END -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added a new --on-question option to control interactive prompt
behavior; client-oriented layout generation now emits client-side config
(public env keys supported).
* **Bug Fixes**
* Improved Bun detection (recognizes both lockfile variants) and
clearer, mode-aware guidance for ambiguous project/package-manager
detection.
* **Chores**
* Test/init scripts updated to use --on-question error for deterministic
non-interactive runs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR adds support for non-interactive initialization in the Stack
Auth initialization script. It introduces a `STACK_DISABLE_INTERACTIVE`
environment variable flag and makes appropriate changes throughout the
codebase to handle non-interactive flows. The changes include improving
type definitions, adding automatic determination of project type (JS vs
Next.js) and configuration (client vs server) when running in
non-interactive mode, and better error handling for cases where required
information is missing. These changes enable CI/CD scenarios and
automation for Stack Auth integration.
⏱️ Estimated Review Time: 0h 20m
<details>
<summary>💡 Review Order Suggestion</summary>
| Order | File Path |
|-------|-----------|
| 1 | `packages/init-stack/src/index.ts` |
</details>
<!-- RECURSEML_SUMMARY:END -->
<!-- RECURSEML_ANALYSIS:START -->
## Review by RecurseML
_🔍 Review performed on
[bba4db2..974e4fd](bba4db2ab0...974e4fda92)_
✨ No bugs found, your code is sparkling clean
<details>
<summary>✅ Files analyzed, no issues (1)</summary>
• `packages/init-stack/src/index.ts`
</details>
[](https://discord.gg/n3SsVDAW6U)
<!-- RECURSEML_ANALYSIS:END -->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Adds non-interactive and React project initialization options to Stack
Auth setup script, updates tests and documentation.
>
> - **Behavior**:
> - Adds `--agent-mode` option in `index.ts` for non-interactive CLI
runs.
> - Adds `--react` option in `index.ts` for React project
initialization.
> - Updates `writeReactClientFile()` in `index.ts` to handle
React-specific setup.
> - **Scripts**:
> - Updates `package.json` to include `test-run-react` and
`test-run-react:manual` scripts.
> - Modifies existing test scripts in `package.json` to use
`--agent-mode`.
> - **Documentation**:
> - Updates `setup.mdx` to include React setup instructions and
wizard/manual tabs.
> - **Misc**:
> - Removes `STACK_DISABLE_INTERACTIVE` checks in `index.ts`.
> - Updates error handling and logging in `index.ts`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for f63a2a57ef. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
----
<!-- ELLIPSIS_HIDDEN -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- First-class React project initialization (--react) with automatic
React client scaffolding.
- Added --agent-mode for fully non-interactive CLI runs and consistent
--no-browser behavior.
- Public env var for local React package override
(STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE).
- Chores
- Standardized non-interactive flows across scripts (removed legacy
interactive gating).
- Tests
- Updated test scaffolding and run commands to use agent-mode and
browser-free execution.
- Documentation
- Converted setup docs to a wizard-style experience with consolidated
wizard/manual tabs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Add CLI options for project ID and publishable client key, update
initialization process, and modify documentation to reflect changes.
>
> - **CLI Options**:
> - Added `--project-id` and `--publishable-client-key` options to
`index.ts` for CLI setup.
> - **Initialization**:
> - Updated `writeEnvVars()` in `index.ts` to include project ID and
publishable client key in `.env.local`.
> - Modified `writeStackAppFile()` in `index.ts` to handle new CLI
options.
> - **Documentation**:
> - Updated references from `stack.ts` to `stack/client.ts` and
`stack/server.ts` in multiple `.mdx` files.
> - Added examples for using project ID and publishable client key in
`setup.mdx` and `example-pages.mdx`.
> - **Testing**:
> - Added `test-run-keys-next` and `test-run-keys-js` scripts in
`package.json` for testing new CLI options.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for b204910ebd. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
----
<!-- ELLIPSIS_HIDDEN -->
<!-- RECURSEML_SUMMARY:START -->
## Review by RecurseML
_🔍 Review performed on
[bd14f6b..92c332a](bd14f6be6a...92c332ad3f)_
✨ No bugs found, your code is sparkling clean
<details>
<summary>✅ Files analyzed, no issues (2)</summary>
• `packages/init-stack/src/index.ts`
•
`apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/new-project/page-client.tsx`
</details>
<details>
<summary>⏭️ Files skipped (trigger manually) (1)</summary>
| Locations | Trigger Analysis |
|-----------|------------------|
`packages/init-stack/package.json` |
[
</details>
[](https://discord.gg/n3SsVDAW6U)
<!-- RECURSEML_SUMMARY:END -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Init tool accepts project ID and publishable client key; generated
projects include those values in client/server outputs and env hints.
- Next.js projects now generate both client and server app artifacts
using a standardized client/server layout.
- UI
- Removed the vertical divider on the New Project page for a cleaner
preview/form layout.
- Documentation
- Updated docs and examples to reference the new client/server file
split.
- Chores
- Added key-based test-run scripts for Next.js and JS.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<img width="474" alt="image"
src="https://github.com/user-attachments/assets/5fb5a632-d605-49ed-89d6-b26533d84a2f"
/>
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Adds `DemoFloatingWindow` component for development, integrated into
demo layout and stack initialization, providing user actions like
sign-in and account settings.
>
> - **Behavior**:
> - Adds `DemoFloatingWindow` component in `demo-floating-window.tsx`,
visible only in development mode.
> - Provides user actions: sign-in, sign-out, account settings.
> - **Integration**:
> - Integrates `DemoFloatingWindow` into `layout.tsx` within the
`StackProvider` and `StackTheme`.
> - Updates `getUpdatedLayout()` in `index.ts` to include
`DemoFloatingWindow` in the layout.
> - **Exports**:
> - Exports `DemoFloatingWindow` in `index.ts` for external use.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 98aa609882. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>