Skip to main content
SolidBase
Beta

Getting Started

SolidBase wraps your SolidStart config rather than wrapping Start itself, so you can add SolidBase to most existing Start projects or create a new one.

Creating a New Project

Follow Start's getting started guide to create a new project. We'd recommend using the basic preset as it includes @solidjs/router, and recommend against the with-mdx preset as SolidBase will provide MDX spport for you.

Adding SolidBase to Your Project

Install @kobalte/solidbase using your preferred package manager.

In your project's app.config, wrap the config being passed to defineConfig with withSolidBase. This will configure SolidBase with the default theme.

app.config.ts
import { defineConfig } from "@solidjs/start/config";
import { withSolidBase } from "@kobalte/solidbase/config";
export default defineConfig(withSolidBase(/* your SolidStart config */));

Add the SolidBaseRoot component to the root of your project's Router.

app.tsx
import { SolidBaseRoot } from "@kobalte/solidbase/client";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
export default function App() {
return (
<Router root={SolidBaseRoot}>
<FileRoutes />
</Router>
);
}

If your router already has a root component, you can wrap it with SolidBaseRoot.

<Router
root={(props) => {
return <SolidBaseRoot>{props.children}</SolidBaseRoot>;
}}
>
<FileRoutes />
</Router>

To provide the lang and data-theme attributes to the html element during SSR, spread getHtmlProps() onto it in entry-server:

entry-server.tsx
// @refresh reload
import { StartServer, createHandler } from "@solidjs/start/server";
import { getHtmlProps } from "@kobalte/solidbase/server";
export default createHandler(() => (
<StartServer
document={({ assets, children, scripts }) => (
<html {...getHtmlProps()}>
...
</html>
)}
/>
));
note

SolidBase prerenders your pages by default, so data-theme will probably be incorrect in the initial HTML. To account for this, a small script will automatically be injected to correct the theme before the page is rendered.

Your project is now setup with the default SolidBase theme!

Edit this page on GitHub

Last updated: 11/15/24, 3:46 AM

SolidBaseFully featured, fully customisable static site generation for SolidStart
Community
githubdiscord