
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
jspsych-vue
Advanced tools
A Vue component for JsPsych.
Compatible with most official plugins and extensions.
Feel free to use any third-party component in JsPsych! 🎉🎉🎉
Use yarn
yarn add jspsych-vue
Use npm
npm install jspsych-vue
In your main.js:
import 'jspsych-vue/dist/style.css'
Then in some where of your vue app:
<template>
<JsPsych ref="jsPsychRef"></JsPsych>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
const jsPsychRef = ref<any>()
onMounted(() => {
jsPsychRef.value.run(trail)
})
</script>
Thats all you need to use JsPsych-Vue.
info property at the top level of the component (see jsPsych Plugin)jsPschy.finishTrial at the appropriate timetrial and on_load props at the appropriate locationsExample:
<template>
<div>Anything you want to show...</div>
</template>
<script>
export default {
setup(props) {
//You can access `props.trial` and `props.on_load` here.
...
},
info: {
parameters: {...}
}
}
</script>
For users of the setup syntax sugar.
Example:
<script setup>
const info = defineOptions({
parameters: {...}
})
</script>
Ensure not to use any local variables within info.
Same as the Plugin’s trial method, the component accepts two props:
trial: Parameters from the parameters object that can be passed in when defining the timelineon_load: Callback function for the load eventPlease refer to the JsPsych documentation for specifics.
In a js file, for instance, timeline/xxx.js in the root directory, define a trials, and set its component attribute to the component you have written.
Example:
//timeline/HelloWorld.ts
import HelloWorld from '@/component/HelloWorld.vue'
const timeline = [{ component: HelloWorld }]
export default timeline
If you need to use a jsPsych instance, you can also export a function.
Example:
//timeline/HelloWorld.ts
import HelloWorld from '@/component/HelloWorld.vue'
const getTimeline (jsPsych: any) = [
{
component: HelloWorld,
on_finish: () => {
//You can use the jsPsych instance somewhere.
}
}
]
export default getTimeline
Note:
Simply put, you can replace the type of certain trials with component while leaving other trials unchanged.
run to start the experiment.Define the location for rendering the component and call run to start the experiment at a specific location.
Example:
<template>
<JsPsych ref="JsPschRef"></JsPsych>
</template>
<script>
import timeline1 from '@/timeline/HellowWorld.ts'
onMounted(() => {
jsPschRef.value.run(timeline1)
})
</script>
Every JsPsych component instantiates a JsPsych object. There are two methods to access the instance.:
The instance is returned during the JsPsych init event.
Example:
<template>
<JsPsych @init="init"></JsPsych>
</template>
<script setup>
let jsPsych;
const init = (instance: any) => jsPsych = instance;
</script>
Using provide within a JsPsych component.
Example:
<script setup>
import { porvice } from 'vue'
const jsPsych = provide('jsPsych')
</script>
JsPsych components accept a property called options which can be used to configure the JsPsych object. The distinction is as follows:
| Parameter | type | Description |
|---|---|---|
| display_element | css selector | It is used to specify the DOM_target in JsPsych, which defaults to body and is related to event listening. The actual display position is specified through the component. |
The JsPsych component has the following methods. Please be mindful not to call methods with the same name on the JsPsych object.
| Name | Type | Description |
|---|---|---|
run | (Trials: any[])=>Promise | To start an experiment, use a function that is equivalent to JsPsych.run |
adaddNodeToEndOfTimeline | (Node: any)=>void | To add a node at the end, use a function that is equivalent to JsPsych.addNodeToEndOfTimeline. |
displayData | (options: {format: string, dom: Element})=>void | To render data on a specified DOM element, use a function that is consistent with JsPsychData.displayData, for other functionalities. |
Other methods of the JsPsych object can be called at will.
JsPsych provides three slots to display at the beginning or end of an experiment.
| Name | Time to use |
|---|---|
| default | Before run called or after options.on_finish called |
| start | before run called |
| finish | after on_finish called |
Note:
When both default and start/finish are defined, start/finish takes priority for display.
The Function Call in the following order:
graph LR
b[default/start.onMounted] --run--> c[options.on_start]
c--do trial-->a[options.on_end]
a-->d[default/end.onMounted]
Example:
<JsPsych>
<template #start>
<p>Welcome!</p>
<p></p
></template>
</JsPsych>
The Example includes:
If you want to run the example, first clone the entire repository
git clone https://github.com/HGGshiwo/jspsych-vue.git
Install the dependencies in the root directory
yarn install
Start the server.
yarn serve
FAQs
Vue3 component for JsPsych
We found that jspsych-vue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.