contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/nextjs.md by scripts/build-agent-skill.mjs. Do not edit. -->
$ npx -y skills add crossbind/crossbind --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
<!-- GENERATED from docs/playbooks/integration/nextjs.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/nextjs.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project is a Next.js app. Detection: `next` in deps, `next.config.{js,mjs,ts}` at root.
> No canonical Next.js example exists in this repo yet. This playbook synthesizes the Webpack and Vite playbooks; verify edge cases against `examples/web-react-rspack/` (the closest equivalent).
Add crossbind to a Next.js app so:
| File | Role | |------|------| | `package.json` | + `crossbind`, `@crossbind/plugin-webpack`, `@crossbind/plugin-webpack-loader`, optional `@crossbind/port-<name>` | | `next.config.{js,mjs,ts}` | Add crossbind plugin via `webpack(config)` callback; add `headers()` for COOP/COEP | | `crossbind.config.{js,mjs}` *(new at root)* | Project-level crossbind config | | `src/native/` *(if user wraps own C++)* | `.h` + `.cpp` source | | `public/` | Next serves `crossbind.js` / `crossbind.wasm` from `public/` if you copy them there post-build (alternative: webpack plugin's middleware) |
pnpm add -D crossbind@beta @crossbind/plugin-webpack@beta @crossbind/plugin-webpack-loader@beta pnpm add @crossbind/port-<name>@beta # optional # Dev pnpm dev # next dev # Production pnpm build && pnpm start # next build && next start
`next.config.mjs`:
import CrossbindWebpackPlugin from '@crossbind/plugin-webpack';
const crossbindWebpackPlugin = new CrossbindWebpackPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config, { isServer }) {
if (!isServer) {
// crossbind targets the client bundle; skip on server-side builds.
config.module.rules.push(crossbindWebpackPlugin.getRule());
config.plugins.push(crossbindWebpackPlugin);
}
return config;
},
async headers() {
return [
{
source: '/:path*',
headers: [
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
{ key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' },
],
},
];
},
};
export default nextConfig;`crossbind.config.mjs`:
export default {
general: { name: 'my-next-app' },
target: { runtime: 'mt' }, // omit for single-thread default
paths: { config: import.meta.url },
};Next 14+ ships Turbopack (`next dev --turbo`, default in Next 15+). **`@crossbind/plugin-webpack` does not run under Turbopack** — Turbopack has its own plugin system that crossbind doesn't yet target.
Workarounds while Turbopack support is pending:
1. Force webpack for dev: drop `--turbo`, run `next dev` (uses webpack). 2. Or build the crossbind artifacts ahead of time and serve them statically:
pnpm crossbind build -p wasm -a wasm32 -e browser -b release cp dist/<name>.browser.* public/
Then `import` the loader from `/crossbind.js` in your component. This skips the bundler integration entirely; you lose HMR for native source changes.
Track Turbopack support: open an issue against this repo if blocking.
The `headers()` callback in `next.config` covers both `next dev` and `next start`. For static export (`next export` / `output: 'export'`), headers won't work — the user must configure their hosting layer (see `docs/playbooks/integration/vite.md` "Multithread → production headers" for per-host recipes).
If `runtime: 'st'`, drop the `headers()` callback.
crossbind targets the **browser bundle**. The `next.config.webpack` callback above gates plugin registration on `!isServer` so SSR/build-time Node bundles don't try to load the wasm.
If the user wants crossbind on the server side too (Node SSR with WASM), that's a separate integration:
Import C++ and Rust like JavaScript modules (WebAssembly & React Native)
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/api/app.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/build-state.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/conan.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/cpp-binding-rules.md by scripts/build-agent-skill.mjs. Do not edit. -->