Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/next-js/src/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getLogger } from "rivetkit/log";

export function logger() {
return getLogger("driver-next-js");
}
9 changes: 9 additions & 0 deletions packages/next-js/src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Registry, RunConfigInput } from "rivetkit";
import { logger } from "./log";

export const toNextHandler = (
registry: Registry<any>,
Expand All @@ -12,6 +13,10 @@ export const toNextHandler = (

// Auto-configure serverless runner if not in prod
if (process.env.NODE_ENV !== "production") {
logger().debug(
"detected development environment, auto-starting engine and auto-configuring serverless",
);

const publicUrl =
process.env.NEXT_PUBLIC_SITE_URL ??
process.env.NEXT_PUBLIC_VERCEL_URL ??
Expand All @@ -21,6 +26,10 @@ export const toNextHandler = (
inputConfig.autoConfigureServerless = {
url: `${publicUrl}/api/rivet/start`,
};
} else {
logger().debug(
"detected production environment, will not auto-start engine and auto-configure serverless",
);
}

// Next logs this on every request
Expand Down
6 changes: 5 additions & 1 deletion packages/rivetkit/src/drivers/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export function chooseDefaultDriver(runConfig: RunnerConfig): DriverConfig {
return runConfig.driver;
}

if (runConfig.endpoint || runConfig.token) {
if (
runConfig.endpoint ||
runConfig.token ||
runConfig.runnerKind === "serverless"
) {
loggerWithoutContext().debug({
msg: "using rivet engine driver",
endpoint: runConfig.endpoint,
Expand Down
Loading