Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@intlify/vue-router-composable
Advanced tools
The universal composable APIs for Vue Router
This library is inspired by vue-demi
useRouter
useRoute
# npm
npm install @intlify/vue-router-composable
# yarn
yarn add @intlify/vue-router-composable
# pnpm
pnpm add @intlify/vue-router-composable
You need to add vue-router
and @vue/composition-api
to your plugin's peer dependencies to specify what versions you support.
{
"dependencies": {
"@intlify/vue-router-composable": "latest"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue-router": "^3.0.0" // or "^4.0.0" base on your preferred working environment
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
},
"devDependencies": {
"vue-router": "^3.0.0" // or "^4.0.0" base on your preferred working environment
},
}
Import everything related to Vue Router from it, it will redirect to vue-router@3
+ @vue/composition-api
or vue-router@4
based on users' environments.
import { useRouter, useRoute } from '@intlify/vue-router-composable'
When using with Vite, you will need to opt-out the pre-bundling to get @intlify/vue-router-composable
work properly by
// vite.config.js
export default defineConfig({
optimizeDeps: {
exclude: ['@intlify/vue-router-composable']
}
})
@intlify/vue-router-composable
provides extra APIs to help distinguish users' environments and to do some version-specific logic.
isVueRouter3
/ isVueRouter4
import { isVueRouter3, isVueRouter4 } from '@intlify/vue-router-composable'
if (isVueRouter3) {
// Vue Router 3 only
} else {
// Vue Router 4 only
}
To explicitly switch the redirecting version, you can use these commands in your project's root:
npx vue-router-switch 2
# or
npx vue-router-switch 3
If you would like to import vue-router
under an alias, you can use the following command:
npx vue-router-switch 2 vue2
# or
npx vue-router-switch 3 vue3
If the postinstall hook doesn't get triggered or you have updated the Vue Router version, try to run the following command to resolve the redirecting:
npx vue-router-fix
You can support testing for both versions by adding npm alias in your dev dependencies. For example:
{
"scripts": {
"test:3": "vue-router-switch 2 vue-router3 && jest",
"test:4": "vue-router-switch 3 && jest",
},
"devDependencies": {
"vue-router": "^4.0.0",
"vue-router3": "npm:vue-router@3"
},
}
or
{
"scripts": {
"test:3": "vue-router-switch 4 && jest",
"test:4": "vue-router-switch 4 vue-router4 && jest",
},
"devDependencies": {
"vue-router": "^3.0.0",
"vue-router4": "npm:vue-router@43"
},
}
This package idea was inspired from vue-demi, @antfus great work!
FAQs
The universal composable for Vue Router
The npm package @intlify/vue-router-composable receives a total of 0 weekly downloads. As such, @intlify/vue-router-composable popularity was classified as not popular.
We found that @intlify/vue-router-composable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.