Show API Reference (openAPI plugin) only in development

Hey, how can i conditionally show the API Reference only in development?
3 Replies
nikatune
nikatune3mo ago
import { betterAuth } from "better-auth"
import { openAPI } from "better-auth/plugins"

export const auth = betterAuth({
plugins: [
process.env.NODE_ENV === "development" && openAPI(),
],
})
import { betterAuth } from "better-auth"
import { openAPI } from "better-auth/plugins"

export const auth = betterAuth({
plugins: [
process.env.NODE_ENV === "development" && openAPI(),
],
})
can u try it?
shadow
shadowOP3mo ago
typescript doesnt like it
No description
shadow
shadowOP3mo ago
import { betterAuth } from "better-auth"
import { openAPI } from "better-auth/plugins"

export const auth = betterAuth({
plugins: [
...(process.env.NODE_ENV === "production" ? [openAPI()] : []),
],
})
import { betterAuth } from "better-auth"
import { openAPI } from "better-auth/plugins"

export const auth = betterAuth({
plugins: [
...(process.env.NODE_ENV === "production" ? [openAPI()] : []),
],
})
this worked

Did you find this page helpful?