wx is an open-source framework that allows you to quickly build Go apps that use Svelte for rendering web pages.
This project was heavily inspired by bud. wx tries to be less opinionated about your Go app build process.
This project is at the very early stage. Do not use it for production! Wait until v1
is released.
go get github.com/apack/wx
go install github.com/apack/wx/cmd/...
Open your Go app folder and initialize views.
wx init
This will create files:
app
├── app.wx.go
├── components
│ ├── Button.svelte
│ └── Counter.svelte
├── gen.go
├── layouts
│ └── DefaultLayout.svelte
├── static
│ └── logo.svg
└── views
└── WelcomeView.svelte
NOTE: Every time you change these files run go generate ./app
.
Load your app and add handler.
package main
import (
"net/http"
"your/path/to/app"
"github.com/apack/wx"
)
func main() {
web := wx.NewRouter()
err := app.Load(web)
if err != nil {
panic(err)
}
web.HandleMethodFunc("GET", "/", handleWelcomeView())
http.ListenAndServe(":8080", web)
}
func handleWelcomeView() wx.HandlerFunc {
return func(ctx *wx.Context) error {
return ctx.View(app.WelcomeView, wx.Props{
"count": 111,
})
}
}
These are the main accomplishments that I want to release with future versions.
Create concept and release it to the public
- Improve view renderer.
- Improve router.
- Add middlewares for CORS, Caching and Compression.
- Make project ready for community contributions.
- Add TypeScript support for Svelte components.
- Add SASS support for Svelte components.
- Add Markdown support for static content.
- Fix memory issue with long-lived v8 isolates. v8go#105
- Create documentation and landing pages using
wx
.
Project is not ready to accept contributors yet. Wait until v0.4
when all of the development documentation and CI is finished.
This work is based off the existing frameworks:
Copyright (c) 2022-present APack and Contributors. wx is free and open-source software licensed under the MIT License.
Third-party library licenses: