Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eznix86/fiber-inertia
This is a Inertia.js server-side adapter based on inertia-laravel, but for Fiber Framework.
https://github.com/eznix86/fiber-inertia
Last synced: 3 months ago
JSON representation
This is a Inertia.js server-side adapter based on inertia-laravel, but for Fiber Framework.
- Host: GitHub
- URL: https://github.com/eznix86/fiber-inertia
- Owner: eznix86
- Created: 2020-09-06T16:08:07.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-06T16:50:54.000Z (about 4 years ago)
- Last Synced: 2024-05-19T05:38:23.694Z (6 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 11
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-inertiajs - Fiber
README
# Inertia.js Golang Adapter (Fiber)
This is a Inertia.js server-side adapter based on inertia-laravel, but for Fiber Framework.
## Installation
```
go get -v github.com/theArtechnology/fiber-inertia
```#### What do you need ?
- Fiber Middleware
```go
app := fiber.New()
// AssetsPath is the path of your assets
app.Use(inertia.New(inertia.Config{
AssetsPath: "./public",
}))
```
- Use `Render` method```go
inertia.Render(c,
"App",
inertia.Map{
"Hello" : "World",
},
)
```
#### Install Client SideUse [official documentation](https://inertiajs.com/client-side-setup) to install client side.
#### Example:
```go
package mainimport (
"fmt"
"github.com/gofiber/fiber"
"github.com/gofiber/template/html"
"github.com/theArtechnology/fiber-inertia/inertia"
"log"
)func main() {
engine := html.New("./public", ".html")
app := fiber.New(&fiber.Settings{
Views: engine,
})
app.Static("/assets", "./public/build")app.Use(inertia.New(inertia.Config{
AssetsPath: "./public",
}))app.Get("/hi", hello)
app.Get("/bonjour", world)
fmt.Println("Server started")
log.Fatal(app.Listen(3001))
}func hello (c *fiber.Ctx) {
inertia.Render(c,
"Main", // Will render component named as Main
inertia.Map{
"Hi-EN" : "Hello World",
},
)
}func world (c *fiber.Ctx) {
inertia.Render(c,
"sub/Users", // Will render component in a subdirectory
inertia.Map{
"Hi-FR" : "Bonjour tout le monde",
},
)
}```