vike-react

The vike-react package is a Vike extension that integrates React in a full-fledged manner, providing a DX like a regular frontend framework such as Next.js.

Source code: GitHub > vikejs/vike-react
Version history: CHANGELOG.md
Examples: Bati and examples/

The documentation for using vike-react can be found throughout this website (vike.dev).

The guides, such as Guides > Data Fetching, assume you're using Vike with vike-react, vike-vue, or vike-solid. If you aren't then see the sections Without vike-{react,vue,solid} such as API > useData() > Without vike-{react,vue,solid}.

You can also integrate React yourself instead of using vike-react, see Integration > React.

Notes about RSC:

Scaffold new vike-react app

Use Bati for creating new apps.

If you select React then Bati scaffolds a Vike + vike-react app.

Add vike-react to existing Vike app

To add vike-react to an existing Vike app: install the vike-react npm package (e.g. $ npm install vike-react) then extend your existing +config.js file (or create one) with vike-react:

// /pages/+config.js
import vikeReact from 'vike-react/config'
 
export default {
  // ...
  extends: [vikeReact] 
}

You can then use new settings introduced by vike-react:

// /pages/+config.js
 
import vikeReact from 'vike-react/config'
 
export default {
  // ...
 
  // Setting to toggle SSR
  ssr: false, 
 
  extends: [vikeReact]
}

Under the hood

The vike-react extension is only 494 lines of code (as of April 2024). Browsing the source code of vike-react is therefore very much an option for deepening your understanding of Vike or for debugging.

Basically vike-react does this:

It implements following features:

For a friendlier list, see the following (which also includes vike-react settings & hooks):

See also