Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Function Runtime Config: Nitro support Bun.js #1040

Closed
TLevesque opened this issue Jan 28, 2025 · 1 comment · Fixed by #1077
Closed

Server Function Runtime Config: Nitro support Bun.js #1040

TLevesque opened this issue Jan 28, 2025 · 1 comment · Fixed by #1077
Assignees

Comments

@TLevesque
Copy link

📚 Subject area/topic

/solid-start/reference/config/define-config.mdx

📋 Page(s) affected (or suggested, for new content)

https://docs.solidjs.com/solid-start/reference/config/define-config
Image

📋 Description of content that is out-of-date or incorrect

Hi,

On this page https://docs.solidjs.com/solid-start/reference/config/define-config of the solidstart documentation, we can see how to setup an alternative server runtime instead of Node.js , like Deno, because it is supported by Nitro (if I do understand well ?), by looking at the Nitro's documentation, I can see that it also support Bun.js as a runtime (https://nitro.build/deploy/runtimes/bun), with the preset "bun". After having a look to the SolidStart's code, if I'm not mistaking, I do not see specific configuration to enable the preset "deno_server", so I guess that with the "bun" preset, it should work too, with very little effort, like:

// app.config.js file 
import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  server: {
    preset: "bun",
  },
});

Even if I tried with the basic project example bellow of a page with a button which call a server function to create a local file with Bun.js method Bun.write("./newfile.txt", "Hello Bun.js"); , and it did not worked (Error: "Bun is not defined"), maybe I missing something within the config of project.

I'm sharing the repo bellow:

Thanks a lot for your feedback.
And if you can help me out to make this configuration work, I'll make PR to complete SolidStart's repo examples with great Bunjs' features within SolidStart.

Best

Image

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

Here the basic repo to try it out: https://github.com/TLevesque/solidstart-bunjs/tree/main

@TLevesque TLevesque added the pending review Awaiting review by team members. label Jan 28, 2025
@amirhhashemi
Copy link
Collaborator

I couldn’t reproduce the error you mentioned.

I used Bun version 1.2.2 to build the repo you shared with this command:

bun run build

Then, I started the server with:

bun run start

After that, I opened http://localhost:3000/ and clicked the "Create File" button. A file called newfile.txt showed up in the root directory with the text "Hello Bun Server Function." So, everything seems to be working as it should.

We will add a link to Nitro's documentation for Bun in our docs. You shouldn’t need any extra configuration apart from that. If you’re still running into the error, please open an issue in the SolidStart repository.

@amirhhashemi amirhhashemi added wait to merge and removed pending review Awaiting review by team members. labels Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants