Environment: server.

This is a beta feature.

If you use config.telefuncFiles, then you also need to set config.root.

// Environment: server
import { config } from 'telefunc'
// Your project's root directory
config.root = __dirname

The config.root setting is only needed if you use config.telefuncFiles.

You usually define server-side configs (import { config } from 'telefunc') at your server entry. For example if you use Express.js:

// /server/index.js
// Environment: server
import express from 'express'
import { config } from 'telefunc'
const app = express()
// Config values can be set here
config.someServerSideSetting = 'some-value'


If you have a monorepo structure, then set config.root to the root directory of your client-side (i.e. the root of Vite/Vike/Next.js/Nuxt/...). Don't set config.root to the monorepo root, nor to the root directory of your server. (The config.root setting enables Telefunc to match your .telefunc.js files/imports between the server-side and the client-side.)

See also