Skip to content

feat: add env:*#2110

Open
lxsmnsyc wants to merge 6 commits intomainfrom
feat-runtime-env
Open

feat: add env:*#2110
lxsmnsyc wants to merge 6 commits intomainfrom
feat-runtime-env

Conversation

@lxsmnsyc
Copy link
Member

@lxsmnsyc lxsmnsyc commented Mar 16, 2026

This PR adds the env:server and env:client modules

// Loads SERVER_* from .env
// Throws and omits all detected variables on client runtime
import { SERVER_EXAMPLE } from 'env:server';

console.log(SERVER_EXAMPLE);

// Loads CLIENT_* from .env
import { CLIENT_EXAMPLE } from 'env:client';

console.log(CLIENT_EXAMPLE);

// Dynamically loads environment variables (only on server)
import env from 'env:server/runtime';

console.log(env.NODE_ENV);

closes #2113

@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

⚠️ No Changeset found

Latest commit: 7415042

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 7415042
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/69b8f3497a76380008255d22
😎 Deploy Preview https://deploy-preview-2110--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/start@2110
npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/vite-plugin-nitro-2@2110

commit: 7415042

const DEFAULT_SERVER_PREFIX = "SERVER_";
const DEFAULT_CLIENT_PREFIX = "CLIENT_";

const SERVER_ONLY_MODULE = `throw new Error('Attempt to load server-only environment variables in client runtime.');`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we error on build-time, instead of run-time?
Maybe if it is done after the server-function & tree-shake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]: 2.0.0-alpha.2 - process.env not available in server functions

2 participants