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

VueGlue implies vue support, what should I use for svelte? #1

Open
Blakeinstein opened this issue Aug 22, 2022 · 6 comments
Open

VueGlue implies vue support, what should I use for svelte? #1

Blakeinstein opened this issue Aug 22, 2022 · 6 comments

Comments

@Blakeinstein
Copy link

Trying out the repo with a svelte app. Confused as to how to set it up.

@torenware
Copy link
Owner

It's actually the same as with Vue or React.

First, let's make sure you actually need vite-go. If you're developing a single page application where you're using a Go backend for the API, you don't really need to use this module. You can just use Vite directly, possibly setting up Vite to proxy over to your Go api server.

The best reason to use the module is if you're developing a Go web app that uses Go's templating system, and you want to enhance that UI with Svelte; vite-go makes this pretty easy. Is that what you're trying to do?

@Blakeinstein
Copy link
Author

No, I do not really need the templating part. I just want to streamline the development and deployment flow of a svelte frontend with go-gin backend.

@torenware
Copy link
Owner

I'm assuming that go-gin exposes a REST backend (haven't used gin yet myself). So you probably just need to set up Vite as a proxy server for your gin API. Here's the place to start with in the docs.

@Blakeinstein
Copy link
Author

I was thinking more towards a) getting vite to proxy when under dev and using the built code as a static route when built for production. b) getting both of those to auto-reload

@kisinga
Copy link

kisinga commented Dec 12, 2022

It's actually the same as with Vue or React.

First, let's make sure you actually need vite-go. If you're developing a single page application where you're using a Go backend for the API, you don't really need to use this module. You can just use Vite directly, possibly setting up Vite to proxy over to your Go api server.

The best reason to use the module is if you're developing a Go web app that uses Go's templating system, and you want to enhance that UI with Svelte; vite-go makes this pretty easy. Is that what you're trying to do?

Why is it optimal to proxy requests via vite?
My use case is I want to eliminate the need for 2 servers, where go does what vite does for SSR while being the API endpoint. Correct me if this is out of scope

@torenware
Copy link
Owner

Why is it optimal to proxy requests via vite?

Mostly this prevents the browser from getting annoyed by cross-domain requests during development. You can certainly configure this yourself, but it's kind of a PITA. Having Vite handle this for you eliminates this problem.

My use case is I want to eliminate the need for 2 servers, where go does what vite does for SSR while being the API endpoint. Correct me if this is out of scope

I'm guessing you mean this feature of Vite. I'll admit I'm not familiar with this feature, so I'm not sure if it's "in scope" or not :-). Unless you mean instead using vite-go to render a production build?

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

No branches or pull requests

3 participants