This is an exploratory project aimed at integrating Jitar with SolidStart and leverage its SSR capabilities.
As of this writing, Jitar does not support Solid or SSR. Please do not expect to find a complete solution yet.
Note: Jitar is already integrated in this example. For integrating it into your own project, a detailed description is provided below. While following along can be useful for learning and experimentation, do not use this approach for production applications.
Simply install the dependencies, and the setup is complete.
npm installThe full build can be performed with a single command.
npm run buildUnder the hood, the build will be performed in two separate steps in this specific order:
- Jitar build
- Solid build
This process creates two important folders:
.jitar- contains the segmented application used by Jitar (domain only).output- contains the fully build application used by Solid (combination of webui and domain, depending on the segmentation)
The Jitar Vite plugin creates an additional bundle for setting up Jitar and adds it to the HTML so that it is loaded by the web browser before rendering any component.
This works out of the box without issues. However, when rendering components on the server side, the same bundle is required. Without it, the server throws an error stating that it cannot find the __run function, which is globally defined by Jitar.
Because Solid support is not yet available, we need to add this bundle to the server manually for now. For this, we need the following files:
- Created Jitar bundle:
.output/public/_build/assets/jitar-bundle-[random].js(the random part differs each build) - Solid server runtime:
.output/server/index.mjs(on older versions:.output/server/chunks/runtime.mjs)
Once located, we import the Jitar bundle at the top in the Solid runtime:
import '../public/_build/assets/jitar-bundle-[random].js';
// other importsSince the bundle is designed for use in a web browser, we need to modify it to provide the Jitar server URL when running on the server side. The quick fix for this specific example looks like this:
// Replace
document.location.origin
// With
globalThis.document?globalThis.document.location.origin:'http://localhost:3001'Important: These steps need to be repeated after each build.
Solid and Jitar both provide their own servers, and therefore need to be started separately using two terminals.
Terminal 1 - Jitar
npm run start-jitarTerminal 2 - Solid
npm run start-solidThe application should be now available at: http://localhost:3000
You should be able to see that the web browser receives he server rendered HTML containing the message provided by Jitar.
These are the steps to integrate Jitar. Follow them to add Jitar to your own project.
For a clean separation of the frontend and domain logic it's recommended to move all Solid code to it's own subfolder like src/webui. This move requires a small addition to the app.config.ts file.
export default defineConfig({
appRoot: "./src/webui", // Add this line
});Next, a separate folder can be added for the domain like src/domain.
First, add the jitar and plugin-vite dependencies to your project:
npm install jitar
npm install --save-dev @jitar/plugin-viteNote that Jitar can also be installed globally for use across multiple projects.
Next, add Jitar configurations to the root of the project:
- segments folder with at least one segment configuration.
- services folder with at least a standalone configuration.
- jitar.json file to configure the correct source and target folders.
- tsconfig-jitar.json file to decouple the domain builds from Solid.
Lastly, add a build and start script to the package.json file.
Examples and values can be found this project's configurations.
Add the Jitar Vite plugin to the app.config.ts file and configure it to the setup created in the previous step.
Perform the following actions in order:
- Run the Jitar build
- Run the Solid build
- Start Jitar
- Start Solid
Then, open the application to see if it works.
From this project, we learned that we need to:
- make our client bundle compatible with server-side clients, and
- create a Solid plugin that dynamically adds the bundle to its runtime.
Both need to be addressed to support SolidStart + SSR in a production‑worthy way.