Next.js Discord

Discord Forum

submit form without reload

Gharial posted this in #help-forum
Open in Discord
hi so Im using query params to do my pagination, my intention is as follow: I want to GET the current route with my new page params, but I want it to load the data only client side. Normally i would use form but form does full reload. and server actions dont support GET method right? currently im using Link but the problem is I when navigating/refetching new page data I want to show loading state in the table but I cant do it with Link. how should I approach this?

2 Replies

fuma 💙 joulev
Why do you mean by form does full reload? You can pass a submit event handler to prevent the full reload:

return <form onSubmit={e => e.preventDefault()}>
Your browser will reload the page when submit event is fired, it's an expected behavior. You have to manually disable it