API Reference
Type Aliases
Adapter
Adapter:
object
A domco adapter that configures the build to a target production environment.
Type declaration
devMiddleware?
optional
devMiddleware:AdapterMiddleware
[]
Middleware to apply in dev
mode.
entry
entry:
AdapterEntry
Entry point for the server application.
message
message:
string
Message to log when the build is complete.
name
name:
string
The name of the adapter.
noExternal?
optional
noExternal:SSROptions
["noExternal"
]
Passed into Vite config.ssr.noExternal
.
previewMiddleware?
optional
previewMiddleware:AdapterMiddleware
[]
Middleware to apply in preview
mode.
run()?
optional
run: () =>any
The script to run after Vite build is complete.
Returns
any
target?
optional
target:SSRTarget
Passed into Vite config.ssr.target
.
Defined in
AdapterBuilder()<AdapterOptions>
AdapterBuilder<
AdapterOptions
>: (AdapterOptions
?) =>MaybePromise
<Adapter
>
Use this type to create your own adapter. Pass any options for the adapter in as a generic.
Type Parameters
• AdapterOptions = never
Parameters
• AdapterOptions?: AdapterOptions
Returns
MaybePromise
<Adapter
>
Defined in
AdapterEntry()
AdapterEntry: (
AdapterEntryOptions
) =>object
A function that returns an additional entry point to include in the SSR build.
Parameters
• AdapterEntryOptions
• AdapterEntryOptions.appId: string
The app entry point to import handler
from.
Returns
object
code
code:
string
Code for the entry point.
id
id:
string
The name of the entry point without extension.
Example
"main";
Defined in
AdapterMiddleware
AdapterMiddleware:
Connect.NextHandleFunction
Middleware used in the Vite server for dev and preview.
Defined in
AppModule
AppModule:
object
Exports from the SSR app
entry point.
Type declaration
handler
handler:
Handler
prerender
prerender:
Prerender
Defined in
DomcoConfig
DomcoConfig:
object
domco Config
Use if you want to create a separate object for your domco config.
Pass the config into the domco
vite plugin.
Type declaration
adapter?
optional
adapter:ReturnType
<AdapterBuilder
>
domco adapter.
Defaults to undefined
- creates a app
build only.
Default
undefined;
Example
import { adapter } from `"domco/adapter/...";`
Example
// vite.config.ts
import { domco, type DomcoConfig } from "domco";
import { defineConfig } from "vite";
const config: DomcoConfig = {
// options...
};
export default defineConfig({
plugins: [domco(config)],
});
Defined in
Handler()
Handler: (
req
) =>MaybePromise
<Response
>
Request handler, takes a web request and returns a web response.
// src/server/+app.ts
import type { Handler } from "domco";
export const handler: Handler = async (req) => {
return new Response("Hello world");
};
Parameters
• req: Request
Returns
MaybePromise
<Response
>
Defined in
Prerender
Prerender:
string
[]
Paths to prerender at build time.
Example
// src/server/+app.ts
import type { Prerender } from "domco";
export const prerender: Prerender = ["/", "/post-1", "/post-2"];
Defined in
Functions
domco()
domco(
domcoConfig
):Promise
<Plugin
<any
>[]>
Creates domco Vite plugin, add to your plugins
array within your vite.config
to start using domco.
Parameters
• domcoConfig: DomcoConfig
= {}
Returns
Promise
<Plugin
<any
>[]>
The domco Vite plugin.
Example
// vite.config.ts
import { domco } from "domco";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [domco()],
});