{"id":19541907,"url":"https://github.com/m1guelpf/ziggy-vapor","last_synced_at":"2026-01-05T14:51:51.991Z","repository":{"id":260213564,"uuid":"805194581","full_name":"m1guelpf/ziggy-vapor","owner":"m1guelpf","description":"Named routes for your Vapor app, both on Swift and on Javascript!","archived":false,"fork":false,"pushed_at":"2024-05-28T18:03:16.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T14:49:51.248Z","etag":null,"topics":["routing","vapor","ziggy"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/m1guelpf/ziggy-vapor","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m1guelpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"m1guelpf"}},"created_at":"2024-05-24T04:34:27.000Z","updated_at":"2025-01-04T21:17:42.000Z","dependencies_parsed_at":"2024-10-30T06:59:20.329Z","dependency_job_id":null,"html_url":"https://github.com/m1guelpf/ziggy-vapor","commit_stats":null,"previous_names":["m1guelpf/ziggy-vapor"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fziggy-vapor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fziggy-vapor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fziggy-vapor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Fziggy-vapor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1guelpf","download_url":"https://codeload.github.com/m1guelpf/ziggy-vapor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467167,"owners_count":20620209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["routing","vapor","ziggy"],"created_at":"2024-11-11T03:12:20.320Z","updated_at":"2026-01-05T14:51:51.954Z","avatar_url":"https://github.com/m1guelpf.png","language":"Swift","funding_links":["https://github.com/sponsors/m1guelpf"],"categories":[],"sub_categories":[],"readme":"# Ziggy for Vapor\n\n\u003e A better way to organize your routes.\n\n[![Swift Version](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fm1guelpf%2Fziggy-vapor%2Fbadge%3Ftype%3Dswift-versions\u0026color=brightgreen)](http://swift.org)\n[![Vapor Version](https://img.shields.io/badge/Vapor-4-30B6FC.svg)](http://vapor.codes)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/m1guelpf/ziggy-vapor/main/LICENSE)\n\n# Installation\n\nAdd `Ziggy` to the package dependencies (in your `Package.swift` file):\n\n```swift\ndependencies: [\n    ...,\n    .package(url: \"https://github.com/m1guelpf/ziggy-vapor.git\", from: \"1.0.0\")\n]\n```\n\nas well as to your target (e.g. \"App\"):\n\n```swift\ntargets: [\n    ...\n    .target(\n        name: \"App\",\n        dependencies: [... \"Ziggy\" ...]\n    ),\n    ...\n]\n```\n\n## Getting started 🚀\n\nImport Ziggy in your `configure.swift` file, then call the `setup` method:\n\n```swift\n// Sources/App/configure.swift\nimport Ziggy\n\n// configures your application\npublic func configure(_ app: Application) async throws {\n    // ...\n\n    app.ziggy.setup()\n\n    // ...\n}\n```\n\nThen, on your `routes.swift` file (or wherever you define your routes), you can chain the `name` method to your routes to give them a name:\n\n```swift\n// Sources/App/routes.swift\nimport Vapor\nimport Ziggy\n\npublic func routes(_ app: Application) throws {\n    app.get { req in\n        return req.view.render(\"dashboard\")\n    }.name(\"dashboard\")\n\n    // ...\n}\n```\n\nYou can then use the `app.route` (or `req.route`) function to generate URLs for your routes:\n\n```swift\nlet url = app.route(\"home\") // /dashboard\nlet edit_user = req.route(\"users.edit\", 1) // /users/1/edit\n\nreturn req.redirect(route: \"user.profile\", \"m1guelpf\") // Redirects to /@m1guelpf\n```\n\nYou can also access the `route` function on your frontend, by adding the `routes` tag to your HTML template and installing [the `ziggy-js` package](https://www.npmjs.com/package/ziggy-js):\n\n```leaf\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n\t\u003chead\u003e\n\t\t\u003cmeta charset=\"utf-8\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"/app.css\" /\u003e\n        \u003cscript type=\"module\" src=\"/app.js\"\u003e\u003c/script\u003e\n\n\t\t#routes()\n\t\u003c/head\u003e\n\n\t\u003cbody\u003e\n\t\t\u003c!-- ... --\u003e\n\t\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## 📄 License\n\nThis package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Fziggy-vapor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1guelpf%2Fziggy-vapor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Fziggy-vapor/lists"}