Skip to content

Commit 71b6a2e

Browse files
authored
Add TanStack Start example integration with Builder.io (#3984)
This PR adds a new example demonstrating the integration of Builder.io with TanStack Router. The example includes: - Server-side rendering (SSR) support - Builder component registry - Catch-all route for Builder pages - Quick setup instructions This helps expand our framework support to include TanStack Start, which is gaining popularity for React applications.
1 parent 8bcaa92 commit 71b6a2e

File tree

17 files changed

+447
-41
lines changed

17 files changed

+447
-41
lines changed

.gitignore

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,7 @@
1-
node_modules
2-
*.log
3-
dist
4-
test-lib/**/*.js
5-
coverage
6-
.history
7-
.nyc_output
8-
.idea
9-
.vscode
10-
.next
11-
firebase.json
12-
temp
13-
yarn-error.log
14-
.build
15-
Pods/
16-
17-
**/xcuserdata/*
18-
**/build/*
19-
20-
**/.pnp.*
21-
**/.yarn/*
22-
!**/.yarn/patches
23-
!**/.yarn/plugins
24-
!**/.yarn/releases
25-
!**/.yarn/sdks
26-
!**/.yarn/versions
27-
28-
# macOS
29-
.DS_Store
30-
31-
.cache
32-
.rpt2_cache/
33-
34-
.env
35-
.vercel
36-
37-
.nx/cache
38-
.nx-cache
39-
.nx/workspace-data
40-
41-
!packages/sdks/e2e/react-native-74/.eas/build/*
1+
/nbproject/
2+
/.idea/*
3+
*.tmlanguage.cache
4+
*.tmPreferences.cache
5+
*.stTheme.cache
6+
*.sublime-workspace
7+
*.sublime-project

examples/tanstack-start/.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
node_modules
2+
package-lock.json
3+
yarn.lock
4+
5+
.DS_Store
6+
.cache
7+
.env
8+
.vercel
9+
.output
10+
.vinxi
11+
12+
/build/
13+
/api/
14+
/server/build
15+
/public/build
16+
.vinxi
17+
# Sentry Config File
18+
.env.sentry-build-plugin
19+
/test-results/
20+
/playwright-report/
21+
/blob-report/
22+
/playwright/.cache/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/build
2+
**/public
3+
pnpm-lock.yaml
4+
routeTree.gen.ts
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// app.config.ts
2+
import { defineConfig } from '@tanstack/react-start/config'
3+
import tsConfigPaths from 'vite-tsconfig-paths'
4+
5+
export default defineConfig({
6+
vite: {
7+
plugins: [
8+
tsConfigPaths({
9+
projects: ['./tsconfig.json'],
10+
}),
11+
],
12+
},
13+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type RegisteredComponent } from "@builder.io/sdk-react";
2+
import { Test } from "./components/test";
3+
4+
export const customComponents: RegisteredComponent[] = [
5+
{
6+
component: Test,
7+
name: "Test",
8+
inputs: [
9+
{
10+
name: "text",
11+
type: "string",
12+
defaultValue: "Hello world",
13+
},
14+
],
15+
},
16+
];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="vinxi/types/client" />
2+
import { hydrateRoot } from 'react-dom/client'
3+
import { StartClient } from '@tanstack/react-start'
4+
import { createRouter } from './router'
5+
6+
const router = createRouter()
7+
8+
hydrateRoot(document, <StartClient router={router} />)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {
2+
Content,
3+
isPreviewing,
4+
} from '@builder.io/sdk-react';
5+
import { ComponentProps } from 'react';
6+
7+
type BuilderContentProps = Omit<ComponentProps<typeof Content>, 'content'> & {
8+
content: any;
9+
}
10+
11+
export function RenderBuilderContent(props: BuilderContentProps) {
12+
// Always render the Content component - it handles the preview mode internally
13+
return <Content {...props} />
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { type ReactNode } from 'react'
2+
3+
interface TestProps {
4+
children?: ReactNode
5+
}
6+
7+
export function Test({ children }: TestProps) {
8+
return (
9+
<div>
10+
<p>Test Component</p>
11+
{children}
12+
</div>
13+
)
14+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// noinspection JSUnusedGlobalSymbols
6+
7+
// This file was automatically generated by TanStack Router.
8+
// You should NOT make any changes in this file as it will be overwritten.
9+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10+
11+
// Import Routes
12+
13+
import { Route as rootRoute } from './routes/__root'
14+
import { Route as SplatImport } from './routes/$'
15+
16+
// Create/Update Routes
17+
18+
const SplatRoute = SplatImport.update({
19+
id: '/$',
20+
path: '/$',
21+
getParentRoute: () => rootRoute,
22+
} as any)
23+
24+
// Populate the FileRoutesByPath interface
25+
26+
declare module '@tanstack/react-router' {
27+
interface FileRoutesByPath {
28+
'/$': {
29+
id: '/$'
30+
path: '/$'
31+
fullPath: '/$'
32+
preLoaderRoute: typeof SplatImport
33+
parentRoute: typeof rootRoute
34+
}
35+
}
36+
}
37+
38+
// Create and export the route tree
39+
40+
export interface FileRoutesByFullPath {
41+
'/$': typeof SplatRoute
42+
}
43+
44+
export interface FileRoutesByTo {
45+
'/$': typeof SplatRoute
46+
}
47+
48+
export interface FileRoutesById {
49+
__root__: typeof rootRoute
50+
'/$': typeof SplatRoute
51+
}
52+
53+
export interface FileRouteTypes {
54+
fileRoutesByFullPath: FileRoutesByFullPath
55+
fullPaths: '/$'
56+
fileRoutesByTo: FileRoutesByTo
57+
to: '/$'
58+
id: '__root__' | '/$'
59+
fileRoutesById: FileRoutesById
60+
}
61+
62+
export interface RootRouteChildren {
63+
SplatRoute: typeof SplatRoute
64+
}
65+
66+
const rootRouteChildren: RootRouteChildren = {
67+
SplatRoute: SplatRoute,
68+
}
69+
70+
export const routeTree = rootRoute
71+
._addFileChildren(rootRouteChildren)
72+
._addFileTypes<FileRouteTypes>()
73+
74+
/* ROUTE_MANIFEST_START
75+
{
76+
"routes": {
77+
"__root__": {
78+
"filePath": "__root.tsx",
79+
"children": [
80+
"/$"
81+
]
82+
},
83+
"/$": {
84+
"filePath": "$.tsx"
85+
}
86+
}
87+
}
88+
ROUTE_MANIFEST_END */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createRouter as createTanStackRouter } from '@tanstack/react-router'
2+
import { routeTree } from './routeTree.gen'
3+
4+
export function createRouter() {
5+
const router = createTanStackRouter({
6+
routeTree,
7+
scrollRestoration: true,
8+
})
9+
10+
return router
11+
}
12+
13+
declare module '@tanstack/react-router' {
14+
interface Register {
15+
router: ReturnType<typeof createRouter>
16+
}
17+
}

0 commit comments

Comments
 (0)