![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
nuxt-query-sync
Advanced tools
This module is a utility designed for Nuxt applications that seamlessly synchronizes Nuxt Ref
or Reactive
objects with URL query parameters. This ensures that the state of your application can be persisted and retrieved via the URL, enhancing the user experience by allowing state to be shared or restored through URLs.
Ref
or Reactive
objects in sync with URL query parameters.Ref
and Reactive
objects with minimal configuration.To use this module in your Nuxt application, follow these steps:
Install the package (assuming it's published on npm, adjust the command if necessary):
# Using npm
$ npm add -D nuxt-query-sync
# Using pnpm
$ pnpm add -D nuxt-query-sync
# Using yarn
$ yarn add -D nuxt-query-sync
# Using bun
$ bun add -D nuxt-query-sync
Add the module to your Nuxt configuration:
// nuxt-config.ts
export default defineNuxtConfig({
modules: ['nuxt-query-sync'],
})
Ref
To persist a Ref
in the URL query parameters, use the usePersistence
function. You need to provide a key
which will be used as the query parameter key.
import usePersistence from 'nuxt-query-sync';
const count = ref(0);
usePersistence(count, 'count');
In this example, the count
Ref
will be synchronized with the count
query parameter. Any changes to count
will update the URL.
Reactive
To persist a Reactive
object, simply pass it to usePersistence
without a key
. The keys of the Reactive
object will be used as query parameter keys.
import usePersistence from 'nuxt-query-sync';
const state = reactive({ name: 'John', age: 30 });
usePersistence(state);
Here, the state
object will be synchronized with corresponding query parameters (e.g., name
and age
).
usePersistence<T>(item: T, key?: string): T
Parameters:
item
: The Nuxt Ref
or Reactive
object to be persisted. If a Ref
, key
must be provided.key
(optional): The query parameter key for Ref
items. Not applicable for Reactive
items.Returns: The original Ref
or Reactive
object with persistence logic applied.
Throws: An error if an unsupported type is provided or if a Ref
is used without a key
.
import usePersistence from 'nuxt-query-sync';
// Example with Ref
const count = ref(0);
usePersistence(count, 'count');
// Example with Reactive
const state = reactive({ name: 'John', age: 30 });
usePersistence(state);
This module is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! Please submit issues or pull requests via GitHub.
For questions or support, please open an issue on GitHub
FAQs
My new Nuxt module
The npm package nuxt-query-sync receives a total of 9 weekly downloads. As such, nuxt-query-sync popularity was classified as not popular.
We found that nuxt-query-sync demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.