Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

ADD-ON-AUTHORING.md

129 lines3.0 KB

Add-on Authoring for the CTA Framework for Solid

Available Integrations

These are the available integration points for the Solid Framework.

header-user

Integrates into the Header component shared by all routes. These components are placed in the right hand side of the header bar.

The code is always integrated into the src/components/Header.(tsx|jsx) file.

Examples

Code in assets/src/components/my-header.tsx:

export default function MyHeader() {
  return <div>Header User</div>
}

Configuration in info.json:

"integrations": [
  {
    "type": "header-user",
    "jsName": "MyHeader",
    "path": "src/components/my-header.tsx"
  },
]

layout

Handles injecting a component into the layout of the page:

The code is integrated into these locations with these application architectures:

  • code-router - In the src/main.tsx (or src/main.jsx) file
  • file-router - In the src/__root.tsx file
  • file-router with start - In the src/main.tsx file

Examples

Code in assets/src/components/my-layout.tsx:

export default function MyLayout() {
  return <div>Hi from MyLayout!</div>
}

Configuration in info.json:

"integrations": [
  {
    "type": "layout",
    "jsName": "MyLayout",
    "path": "src/components/my-layout.tsx"
  },
]

provider

Handles placing UI style provider wrappers into the right spot in three different applicatin setups:

The code is integrated into these locations with these application architectures:

  • code-router - In the src/main.tsx (or src/main.jsx) file
  • file-router - In the src/__root.tsx file
  • file-router with start - In the src/main.tsx file

Examples

Code in assets/src/components/my-provider.tsx:

export default function MyProvider({ children }: { children: React.ReactNode }) {
  return <SomeKindOfProvider>{children}</SomeKindOfProvider>
}

Configuration in info.json:

"integrations": [
  {
    "type": "provider",
    "jsName": "MyProvider",
    "path": "src/components/my-provider.tsx"
  },
]

Routes

If your add-on creates routes you need to specify those in the info.json file.

This example will define a route at /demo/my-demo-route that will be rendered by the DemoMyDemoRoute component. There will be a Demo Route link in the header to this route.

"routes": [
  {
    "url": "/demo/my-demo-route",
    "name": "Demo Route",
    "path": "src/routes/demo.my-demo-route.tsx",
    "jsName": "DemoMyDemoRoute"
  }
],

If you don't want a header link you can omit the url and name properties.

"routes": [
  {
    "path": "src/routes/demo.my-hidden-demo-route.tsx",
    "jsName": "DemoMyHiddenDemoRoute"
  }
],

You MUST specify routes in the info.json file if your add-on supports the code-router mode. This is because the code-routers setup needs to import the routes in order to add them to the router.

By convension you should prefix demo routes with demo to make it clear that they are demo routes so they can be easily identified and removed.