Next.js Discord

Discord Forum

submit form without reload

Unanswered
Gharial posted this in #help-forum
Open in Discord
Avatar
GharialOP
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

Avatar
fuma & joulev pray for Schneider
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()}>
  ...
</form>
Your browser will reload the page when submit event is fired, it's an expected behavior. You have to manually disable it