Skip to content
On this page

Configuration

Configuring Spire

Spire follows convention over configuration when possible - but certain things need to be configured differently per app.

Anything that is configurable has its own config file within config/

Reasonable defaults have been set so you might not even need to configure anything.

Generic Config Composable

Spire has a useConfig composable that provides a generic, streamlined way of configuring Spires composables or even your own custom composables.

On the composable side:

ts
type RoutesConfig = {
    baseUrl: string
    defaultLayout?: () => Promise<Component>
}

const { 
    getConfig: getRoutesConfig, 
    setConfig: setRoutesConfig 
} = useConfig<RoutesConfig>({
    baseUrl: "",
})

export { getRoutesConfig, setRoutesConfig }

On the config side:

ts
import { setRoutesConfig } from "@/framework/composables/useRoutes"

setRoutesConfig({
    baseUrl: import.meta.env.BASE_URL,
    defaultLayout: async () => import("@/ui/layouts/AppLayout.vue"),
})

TIP

You can change the config at runtime, if needed!