You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

ziggy-js

Package Overview
Dependencies
Maintainers
0
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ziggy-js - npm Package Compare versions

Comparing version

to
2.4.0

5

package.json
{
"name": "ziggy-js",
"version": "2.3.1",
"version": "2.4.0",
"description": "Use your Laravel named routes in JavaScript.",

@@ -59,2 +59,3 @@ "keywords": [

"devDependencies": {
"@types/qs": "^6.9.17",
"jsdom": "^25.0.1",

@@ -64,3 +65,3 @@ "microbundle": "^0.15.1",

"typescript": "^5.6.3",
"vitest": "^2.1.3"
"vitest": "^2.1.4"
},

@@ -67,0 +68,0 @@ "prettier": {

12

README.md

@@ -47,3 +47,3 @@ ![Ziggy - Use your Laravel routes in JavaScript](https://raw.githubusercontent.com/tighten/ziggy/main/ziggy-banner.png)

Ziggy's `route()` function works like [Laravel's `route()` helper](https://laravel.com/docs/10.x/helpers#method-route)—you can pass it the name of a route, and the parameters you want to pass to the route, and it will generate a URL.
Ziggy's `route()` function works like [Laravel's `route()` helper](https://laravel.com/docs/helpers#method-route)—you can pass it the name of a route, and the parameters you want to pass to the route, and it will generate a URL.

@@ -382,2 +382,12 @@ #### Basic usage

With `<script setup>` in Vue 3 you can use `inject` to make the `route()` function available in your component script:
```vue
<script setup>
import { inject } from 'vue';
const route = inject('route');
</script>
```
If you are not using the `@routes` Blade directive, import Ziggy's configuration too and pass it to `.use()`:

@@ -384,0 +394,0 @@

@@ -0,1 +1,3 @@

import { ParsedQs } from 'qs';
/**

@@ -9,2 +11,7 @@ * A list of routes and their parameters and bindings.

/**
* Marker interface to configure Ziggy's type checking behavior.
*/
export interface TypeConfig {}
/**
* A route name registered with Ziggy.

@@ -17,3 +24,5 @@ */

*/
type RouteName = KnownRouteName | (string & {});
type RouteName = TypeConfig extends { strictRouteNames: true }
? KnownRouteName
: KnownRouteName | (string & {});
// `(string & {})` prevents TypeScript from reducing this type to just `string`,

@@ -164,3 +173,3 @@ // which would prevent intellisense from autocompleting known route names.

get routeParams(): Record<string, string>;
get queryParams(): Record<string, string>;
get queryParams(): ParsedQs;
has<T extends RouteName>(name: T): boolean;

@@ -174,2 +183,11 @@ }

export function route(): Router;
// Called with configuration arguments only - returns a configured Router instance
export function route(
name: undefined,
params: undefined,
absolute?: boolean,
config?: Config,
): Router;
// Called with a route name and optional additional arguments - returns a URL string

@@ -182,2 +200,3 @@ export function route<T extends RouteName>(

): string;
export function route<T extends RouteName>(

@@ -189,9 +208,2 @@ name: T,

): string;
// Called with configuration arguments only - returns a configured Router instance
export function route(
name: undefined,
params: undefined,
absolute?: boolean,
config?: Config,
): Router;

@@ -198,0 +210,0 @@ /**